Quantity Queries 项目教程
1. 项目的目录结构及介绍
Quantity Queries 项目的目录结构如下:
quantity-queries/
├── github/
│ └── workflows/
├── src/
├── tests/
├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── package.json
├── quantity-queries.gemspec
├── sache.json
└── yarn.lock
目录结构介绍
- github/workflows/: 包含 GitHub Actions 的工作流配置文件。
- src/: 包含项目的源代码,主要是 Sass 文件。
- tests/: 包含项目的测试文件。
- .gitignore: 指定 Git 忽略的文件和目录。
- CHANGELOG.md: 记录项目的变更日志。
- LICENSE: 项目的开源许可证文件。
- README.md: 项目的介绍和使用说明。
- package.json: 项目的 npm 配置文件。
- quantity-queries.gemspec: 项目的 RubyGems 配置文件。
- sache.json: 项目的 Sache 配置文件。
- yarn.lock: 项目的 Yarn 锁定文件。
2. 项目的启动文件介绍
Quantity Queries 项目的主要启动文件是 src/
目录下的 Sass 文件。这些文件定义了项目的核心功能,即数量查询的 Sass 混合器。
主要启动文件
- src/quantity-queries.scss: 这是项目的主要入口文件,包含了所有的数量查询混合器。
启动文件介绍
- at-least($count, $selector): 当元素包含
$count
个或更多项目时,应用样式。 - at-most($count, $selector): 当元素包含
$count
个或更少项目时,应用样式。 - between($first, $last, $selector): 当元素包含
$first
到$last
个项目时,应用样式。 - exactly($count, $selector): 当元素包含恰好
$count
个项目时,应用样式。 - even($selector): 当元素包含偶数个项目时,应用样式。
- odd($selector): 当元素包含奇数个项目时,应用样式。
- multiple-of($count, $selector): 当元素包含
$count
的倍数个项目时,应用样式。
3. 项目的配置文件介绍
package.json
package.json
文件是 npm 项目的配置文件,包含项目的元数据和依赖项。
{
"name": "quantity-queries",
"version": "1.0.0",
"description": "Simple quantity queries mixins for Sass",
"main": "src/quantity-queries.scss",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Daniel Guillan",
"license": "MIT",
"devDependencies": {
"sass": "^1.32.0"
}
}
quantity-queries.gemspec
quantity-queries.gemspec
文件是 RubyGems 的配置文件,用于发布 Ruby 库。
Gem::Specification.new do |s|
s.name = 'quantity-queries'
s.version = '1.0.0'
s.date = '2021-01-01'
s.summary = "Simple quantity queries mixins for Sass"
s.description = "Use quantity as a condition to style your items"
s.authors = ["Daniel Guillan"]
s.email = 'daniel.guillan@gmail.com'
s.files = ["lib/quantity-queries.rb"]
s.homepage = 'https://github.com/danielguillan/quantity-queries'
s.license = 'MIT'
end
sache.json
sache.json
文件是 Sache 的配置文件,用于在 Sache 上发布 Sass 库。
{
"name": "Quantity Queries",
"description": "Simple quantity queries mixins for Sass",
"tags": ["sass", "quantity", "queries"]
}
.gitignore
.gitignore
文件指定 Git 忽略的文件和目录。
node_modules/
*.log
*.lock
CHANGELOG.md
CHANGELOG.md
文件记录项目的变更日志。
# Changelog
## 1.0.0 (2021-01-01)
- Initial release
LICENSE
LICENSE
文件是项目的开源许可证文件。
MIT License
Copyright (c) 2021 Daniel Guillan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
README.md
README.md
文件是项目的介绍和使用说明。
# Quantity Queries
Simple quantity queries mixins for Sass. Use quantity as a condition to style your items.
## Installation
Using npm:
```bash
npm install --save-dev quantity-queries
Using Yarn:
yarn add --dev quantity-queries
Usage
Import the library:
// Dart Sass
@use 'quantity-queries';
// LibSass
@import 'quantity-queries/legacy';
Mixins
at-least($count, $selector)
at-most($count, $selector)
between($first, $last, $selector)
exactly($count, $selector)
even($selector)
odd($selector)
multiple-of($count, $selector)
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考