@adaws/flip-card 中文文档教程

发布于 5 年前 浏览 5 项目主页 更新于 2 年前

Published on webcomponents.org

Flip Card Component

基于 Dan Harding 的代码注释的卡片组件。 flip-card 元素可用于在页面上创建卡片式组件,包括正面和背面。 用户可以点击卡片的左下角查看是否翻转,露出另一面。

Installation

从 npm 安装组件:

npm install --save flip-card

或者,如果您不使用 npm,则可以在 bundle/flip-card.js 获得捆绑组件。 然而,这包括汇总的整个 Lit-Element 库(总计约 22KB)。

Usage

将模块导入您的 .html 文件:

<script type="module" src="path/to/flip-card.js"></script>

或 .js 文件:

import('path/to/flip-card.js');

然后像使用任何其他 HTML 标记一样使用它:

<flip-card></flip-card>

可以通过向元素添加子元素并为其 slot 属性指定以下名称之一来编辑卡片上的内容:

Slot Name Description
front-content The content for the front of the card
back-content The content for the back of the card

插槽内容可以像页面上的任何其他元素一样,仅使用 css 设置样式。

Attributes

Attrbiute Name Type Description
facedown boolean Show the back side of the card.

Styling

卡片可以通过设置 css 变量来设置样式。 可以设置的变量有:

Variable Description
accent Set the colour of the card border and flip button background. Defaults to rgb(255, 212, 45)
flipButtonColour Set the colour of the flip button icon. Defaults to #000000

以下 css 将页面上所有翻页卡片的强调色设置为绿色:

flip-card {
  --accent: green;
}

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Credits

基于 Dan Harding 的 >Code-it Notes,
由 Alex Dawson 实施,

License

根据 The Unlicense 获得许可

Published on webcomponents.org

Flip Card Component

A card component based on the code-it notes by Dan Harding. flip-card elements can be used to create card style components on the page, with a front and back. The user can click the bottom left corner of the card to see if flip over, revealing its other side.

Installation

Install the component from npm:

npm install --save flip-card

or if you aren't using npm, a bundled component is available at bundle/flip-card.js. However this includes the whole Lit-Element library rolled up (~22KB total).

Usage

Import the module to your .html file:

<script type="module" src="path/to/flip-card.js"></script>

or .js file:

import('path/to/flip-card.js');

Then use it like you would any other HTML tag:

<flip-card></flip-card>

The content on the card can be edited by adding children to the element and giving their slot attribute one of the following names:

Slot Name Description
front-content The content for the front of the card
back-content The content for the back of the card

Slotted content can be styled just using css, like any other element on the page.

Attributes

Attrbiute Name Type Description
facedown boolean Show the back side of the card.

Styling

Cards can be styled by setting css variables. The variables that can be set are:

Variable Description
accent Set the colour of the card border and flip button background. Defaults to rgb(255, 212, 45)
flipButtonColour Set the colour of the flip button icon. Defaults to #000000

The following css sets the accent colour for all flip-cards on the page to green:

flip-card {
  --accent: green;
}

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Credits

Based on Code-it Notes by Dan Harding,
Implemented by Alex Dawson

License

Licensed under The Unlicense

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文