HowTo: Components

常见 UI 模式的识字代码示例。「Literate code examples for common UI patterns.」

  • Owner: GoogleChromeLabs/howto-components
  • Platform: Docker, Linux, Mac, Windows
  • License:: Apache License 2.0
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

HowTo: 组件

"HowTo: 组件" 是 基础架构部分的一个小节,其中包含了一系列使用现代 Web 技术(如 Custom Elements v1 和 ESnext)实现常见 Web UI 模式的 Web 组件,特别关注可访问性、性能和逐步增强。它们的目的是成为一种教育资源。用户应该阅读并从他们的实现中学习。它们显然不是一个用于生产的 UI 库。

演示

你可以在本地运行 demo,在你构建它们之后。

npm install  # 如果你还没有安装的话
npm run build
python -m SimpleHTTPServer  # 或者你最喜欢的本地服务器

在你的浏览器中,导航到 http://localhost:8000/docs(或你运行本地服务器的端口)。

你也可以运行

npm run watch

每当文件发生变化时,就会持续运行构建。

WebFundamentals

要生成 WebFundamentals 的内容,运行 build-webfundamentals.sh 脚本。它将创建一个 webfundamentals 文件夹。这些内容需要被移动到 WebFundamentals 资源库中。如果已经创建了新的组件,则需要手动将它们添加到 WebFundamentals Web Components 目录中

测试

测试是用 MochaChai 编写的。每个组件都有测试。

本地

使用 Karma 运行测试。运行测试时使用

$ npm test

这是假设安装了 Chrome、Firefox 和 Safari,因为测试在所有这些浏览器中运行(使用 Custom Elements v1 Polyfill)。

本地 + Docker (或 Travis)

测试也可以在 Docker 容器中运行(就像我们在 Travis 上做的那样)。

$ npm run docker

这将构建一个 docker 镜像 googlechrome/howto-components 并运行它。docker 化测试只使用 Chrome。

暂存

所有的分支和 PR 都是在 Travis CI 上构建和上传的。分期版本可以在 http://dash-elements.surma.link/上查看。

许可证

Copyright 2017 Google, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Please note: this is not a Google product

Main metrics

Overview
Name With OwnerGoogleChromeLabs/howto-components
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 4)
PlatformDocker, Linux, Mac, Windows
License:Apache License 2.0
所有者活动
Created At2017-01-11 01:46:19
Pushed At2025-03-11 00:14:50
Last Commit At2017-10-10 16:24:46
Release Count0
用户参与
Stargazers Count870
Watchers Count51
Fork Count73
Commits Count239
Has Issues Enabled
Issues Count74
Issue Open Count32
Pull Requests Count50
Pull Requests Open Count19
Pull Requests Close Count19
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

HowTo: Components

Travis CI Build status badge

“HowTo: Components” is a subsection on Web Fundamentals Architecture section, containing a collection of web components that implement common web UI patterns using modern web technologies like Custom Elements v1 and ESnext with a special focus on accessibility, performance and progressive enhancement. Their purpose is to be an educational resource. Users are supposed to read and learn from their implementations. They are explicitly NOT a UI library meant to be used in production.

Demos

You can run the demos locally, after you build them:

npm install  # if you haven't already
npm run build
python -m SimpleHTTPServer  # or your favourite local server

In your browser, navigate to http://localhost:8000/docs (or the port that you're running the local server from.)

You can also run

npm run watch

to continuously run the build whenever a file changes.

WebFundamentals

To generate the content for WebFundamentals, run the build-webfundamentals.sh script. It will create a webfundamentals folder. The contents needs to be moved into the WebFundamentals repository. If new components have been created, they need to be added manually to WebFundamentals Web Components table of contents.

Testing

Tests are written using Mocha and Chai. Each component has tests.

Local

Tests run using Karma. Run the tests with

$ npm test

This assumes that Chrome, Firefox and Safari are installed as the tests run in all of these browser (using the Custom Elements v1 Polyfill).

Local + Docker (or Travis)

Tests can also run in a Docker container (as we do on Travis):

$ npm run docker

This builds a docker image googlechrome/howto-components and runs it. The dockerized tests use Chrome only.

Staging

All branches and PRs are built and uploaded on Travis CI. The staged version can be viewed at http://dash-elements.surma.link/<commit hash>.

License

Copyright 2017 Google, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Please note: this is not a Google product