@4alldigital/scut 中文文档教程

发布于 3年前 浏览 45 项目主页 更新于 3年前

Scut

updated/patched forked version from https://www.npmjs.com/package/scut.

— 一组 Sass 实用程序,用于简化和改进我们对常见样式代码模式的实现。

要详细了解 Scut,阅读关于 CSS 技巧的“介绍 Scut”

如果您对 Sass 有任何疑问,可以在 Sass 的精美文档 中找到答案。

Installing and Using

请访问此处的完整文档:
http://davidtheclark.github.io/scut/

应该在那里解释用法,就像安装一样。 但为了您的方便,我也会在这里解释安装。 您可以通过以下方式安装 Scut:

  • Using Bower: bower install scut --save-dev.
  • Downloading the file from the latest release.
  • Using Scut as a Compass extension by installing the RubyGem (gem install scut) and then performing the usual Compass require and @import business.
  • Using node-sass and eyeglass:
  • npm install --save-dev scut
  • setup render per eyeglass instructions
  • in sass files: @import 'scut'

Contributing

请执行! Scut 很简单; 贡献应该很容易。 所以试一试吧。

如果您有任何疑问,如果关于本文档的任何内容不清楚或不准确,如果您不知道该怎么做,请提交问题或联系我。

Approach

Scut 实用程序应该帮助用户避免重复、组织代码和重用代码

Scut 实用程序应该解决遭受以下一个或多个问题的模式:

  1. The pattern is non-intuitive.
  2. The pattern deserves a shorthand.
  3. The pattern involves some important best practices.
  4. The pattern is extremely common and (at least) a little annoying.

该实用程序的目标是以最大限度地提高可重用性 的方式解决这些问题。 这里有一些要记住的原则,以最大限度地提高可重用性:

  • Include sufficient detail to implement the pattern, but no more.
  • Use arguments to allow for typical variations on the theme.
  • Arrange those arguments according to the likelihood that users will want to change them.
  • Namespace (notice the scut- prefix everwhere).
  • Document thoroughly.

我在 那篇 CSS 技巧文章

Development Requirements

Writing Scut Utilities

实用程序位于 src/ 中,按类别组织。 src/ 中的 SCSS 样式表最终连接到 dist/_scut.scss< /code>,这是用户 @import 到他们自己的 Sass 中的内容。

Scut's SCSS Styleguide

请查看 src/ 中现有的 SCSS 文件并尝试匹配它们的样式。

(或者,如果您认为有更好的方法,请提交问题.)

这里有一些指导方针来解释我是如何写作的:

  • Head the file with a multi-line comment (each line an inline // comment, not a block comment) naming the utility and listing any dependencies. Limit dependencies please. In the end, that top comment should also contain the URL of the utility's documentation. For example:
// SCUT PIXELS TO EMS
// http://davidtheclark.github.io/scut/#pixels-to-ems

// Depends on `scut-strip-unit`.
  • Indent with two spaces.
  • List arguments on separate lines, so they are easy to scan. For example:
@mixin scut-color-swap (
  $inactive,
  $active,
  $duration: 0,
  $bg: false
) {
  // mixin content
}
  • Space liberally. A space at the beginning and end of mixins and functions helps distinguish the arguments from the inner workings. Spacing can also help delineate different "sections" of the code by grouping rules that work together and separating those with different roles.

Experimenting and Testing

我推荐的实验和测试方法是使用 Codepen从头开始自己的笔或分叉 Scut Playground(导入最新版本的 Scut)。

(我已经从存储库中删除了“测试”目录和任务,转而依赖 Codepen。)

Documenting

文档是使用 Assemble 编译的。 源文件位于 docs/contentdocs/dev 中。 您需要 bower install 才能获得 Normalize。

Scut

updated/patched forked version from https://www.npmjs.com/package/scut.

— a collection of Sass utilities to ease and improve our implementations of common style-code patterns.

For a prolonged introduction to Scut, read "Introducing Scut" on CSS-Tricks.

If you have any questions about Sass, they are answered in Sass's fine documentation.

Installing and Using

Please visit the complete documentation here:
http://davidtheclark.github.io/scut/

Usage should be explained there, as is installation. But I'll explain installation here, too, for your convenience. You can install Scut by:

  • Using Bower: bower install scut --save-dev.
  • Downloading the file from the latest release.
  • Using Scut as a Compass extension by installing the RubyGem (gem install scut) and then performing the usual Compass require and @import business.
  • Using node-sass and eyeglass:
  • npm install --save-dev scut
  • setup render per eyeglass instructions
  • in sass files: @import 'scut'

Contributing

Please do! Scut is simple; contributing should be easy. So give it a go.

If you have any questions, if anything about this document is unclear or inaccurate, if you can't figure out what to do, please file an issue or contact me.

Approach

Scut utilities should help users avoid repetition, organize code, and re-use code.

Scut utilities should tackle patterns that suffer from one or more of the following problems:

  1. The pattern is non-intuitive.
  2. The pattern deserves a shorthand.
  3. The pattern involves some important best practices.
  4. The pattern is extremely common and (at least) a little annoying.

The utility's goal is to fix those problems in a way that maximizies reusability. Here are some principles to keep in mind to maximize that reusability:

  • Include sufficient detail to implement the pattern, but no more.
  • Use arguments to allow for typical variations on the theme.
  • Arrange those arguments according to the likelihood that users will want to change them.
  • Namespace (notice the scut- prefix everwhere).
  • Document thoroughly.

I go into detail about all these ideas in that CSS-Tricks article.

Development Requirements

Writing Scut Utilities

The utilities are in src/, organized by category. The SCSS stylesheets in src/ ultimately concatenate into dist/_scut.scss, which is what users @import into their own Sass.

Scut's SCSS Styleguide

Please have a look at existing SCSS files within src/ and try to match their style.

(Or, if you think there's a better way to do things, please file an issue.)

Here are some guidelines to explain how I've been writing:

  • Head the file with a multi-line comment (each line an inline // comment, not a block comment) naming the utility and listing any dependencies. Limit dependencies please. In the end, that top comment should also contain the URL of the utility's documentation. For example:
// SCUT PIXELS TO EMS
// http://davidtheclark.github.io/scut/#pixels-to-ems

// Depends on `scut-strip-unit`.
  • Indent with two spaces.
  • List arguments on separate lines, so they are easy to scan. For example:
@mixin scut-color-swap (
  $inactive,
  $active,
  $duration: 0,
  $bg: false
) {
  // mixin content
}
  • Space liberally. A space at the beginning and end of mixins and functions helps distinguish the arguments from the inner workings. Spacing can also help delineate different "sections" of the code by grouping rules that work together and separating those with different roles.

Experimenting and Testing

The method I recommend for experimentation and testing is to use Codepen, either starting your own pen from scratch or forking the Scut Playground (which imports the latest version of Scut).

(I have deleted the "tests" directory and tasks from the repository in favor of relying on Codepen.)

Documenting

Documentation is compiled using Assemble. The source files are located in docs/content and docs/dev. You'll need to bower install to get Normalize.

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