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 目录中。
测试
测试是用 Mocha 和 Chai 编写的。每个组件都有测试。
本地
使用 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