seek-style-guide

授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发、 常用JavaScript包
软件类型 开源软件
地区 不详
投 递 者 段干子晋
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

⚠️ NOTE: This project has been deprecated in favour of Braid Design System.


seek-style-guide

Living style guide for SEEK, powered by React, webpack, CSS Modules and Less.

If you're creating a new project from scratch, consider using sku, our officially supported front-end development toolkit. It's specially designed to get your project up and running as quickly as possible, while simplifying the process of keeping your development environment up to date.

If you'd instead like to work on a custom webpack project, you can use seek-style-guide-webpack to streamline the integration process.

Installation

$ npm install --save seek-style-guide react react-dom react-helmet

Optionally, if not making use of the React components, you can install seek-style-guide by itself:

$ npm install --save seek-style-guide

Upgrading

Consumers can stay up to date by following our release notes, which are published automatically whenever a new release is published to npm.

Setup

Wrap your app with the StyleGuideProvider component to use any of the style guide components. For example:

import React, { Component } from 'react';
import { StyleGuideProvider } from 'seek-style-guide/react';

export default class App extends Component {
  render() {
    const locale = 'AU';
    const title = '...';
    const meta = [{ name: 'description', content: '...' }];
    const link = [{ rel: 'canonical', href: 'https://www.seek.com.au/' }];

    return (
      <StyleGuideProvider locale={locale} title={title} meta={meta} link={link}>
        ...
      </StyleGuideProvider>
    );
  }
}

StyleGuideProvider's props are used to set the page head properties using Helmet.

High Level Components

As much as possible, you should aim to minimise the amount of custom CSS you need to write. This is achieved by leveraging our suite of high level components, which are demonstrated on our style guide documentation site.

Low Level Styling

For more advanced pages, if you need to drop down into Less, the style guide provides a set of mixins and variables to make it easier to stay on brand.

In any style sheet that depends on the style guide, first import the Less theme by reference.

@import (reference) '~seek-style-guide/theme';

Responsive Breakpoint

The style guide exposes one responsive breakpoint:

@responsive-breakpoint: 740px;

Content should otherwise be responsive within its container. The set of included components follow this model internally if you'd like to get a sense of what this looks like in practice.

Color Variables

As much as possible, colors should be directly imported from the style guide.

The following colors are provided:

// Brand colors
@sk-blue-darker;
@sk-blue-dark;
@sk-blue;
@sk-blue-light;
@sk-blue-lighter;
@sk-pink;
@sk-green;
@sk-green-light;
@sk-purple;
@sk-teal;
@sk-orange;
@sk-yellow;
@sk-yellow-light;

// Partner brand colors
@sk-business;
@sk-volunteer;
@sk-learning-light;
@sk-learning-medium;
@sk-learning-dark;

// Grays
@sk-black;
@sk-charcoal;
@sk-mid-gray-dark;
@sk-mid-gray-medium;
@sk-mid-gray;
@sk-mid-gray-light;
@sk-gray-light;
@sk-gray-lightest;
@sk-off-white;
@sk-white;

// Element colors
@sk-link;
@sk-link-visited;
@sk-focus;
@sk-footer;
@sk-background;
@sk-form-accent;
@sk-positive-light;
@sk-positive;
@sk-info-light;
@sk-info;
@sk-critical-light;
@sk-critical;
@sk-help-light;
@sk-help;

Z-Indexes

To ensure correct relative elements stacking order, z-index variables are provided:

@z-index-header-overlay;
@z-index-header;
@z-index-page-overlay;
@z-index-inline-overlay;
@z-index-negative;

Accessible Color Variants

The contrast ratio of certain foreground/background color combinations don't meet the AA accessibility standards that we aim for. As a result, a suite of accessible variants have been provided:

@sk-mid-gray-on-white;
@sk-pink-on-gray-light;
@sk-learning-dark-on-gray-light;
@sk-business-on-gray-light;
@sk-link-on-mid-gray-light;
@sk-mid-gray-dark-on-gray-light;

Please note that this list is not exhaustive, so contributions are encouraged. To validate color combinations, we recommend the use of the web-based tool Accessible Colors by @moroshko.

Grid Variables

In order to ensure elements correctly follow the grid, element sizing should always be controlled by the following variables:

@row-height;
@gutter-width;
@column-width;
@container-width;

When defining a document content container:

.element {
  max-width: @container-width;
}

When defining heights and vertical padding/margins:

.element {
  height: (@row-height * 3);
  padding-bottom: @row-height;
  margin-bottom: @row-height;
}

When defining widths and horizontal padding/margins:

.element {
  width: (@column-width * 3);
  padding-right: @gutter-width;
  margin-right: @column-width;
}

It's important to note that any additions to these values (e.g. borders) will need to be negated to maintain rhythm:

.element {
  @border-width: 1px;
  border-bottom: @border-width solid @sk-charcoal;
  padding-bottom: @row-height - @border-width;
}

Advanced Usage

Babel Plugin

Note: If you're using sku, this plugin is already enabled.

In order to help you optimise your bundle size, you can use babel-plugin-seek-style-guide.

$ npm install --save-dev babel-plugin-seek-style-guide

Then, add seek-style-guide to the plugins list in your Babel config. For example, in .babelrc:

{
  "plugins": ["seek-style-guide"]
}

Flow Type Checking

We've opted to include flow type checking in this project. If you're unfamiliar with static type checking you should start by reading React's overview.

This is completely opt-in and if you've decided not to use type checking in your project then there is nothing you need to do. It shouldn't impact your ability to include the style guide so long as you are using either sku or our webpack decorator.

Conversely, if you would like to opt-in to flow types you'll need to ensure that your .flowconfig includes a few exclusions and special options.

[ignore]
.*/node_modules/config-chain/.*
.*/node_modules/npmconf/.*

[include]

[libs]

[lints]

[options]
# This is required to prevent errors to less file imports
module.name_mapper.extension='less' -> '<PROJECT_ROOT>/no-declarations.js.flow'

# Good idea to ignore json too
module.name_mapper.extension='json' -> '<PROJECT_ROOT>/no-declarations.js.flow'

no-declarations.js.flow is just an empty file

Sketch asset generation

On every successful build (via npm test), asketch.json files (i.e. almost Sketch files) are generated by html-sketchapp containing document styles and symbols. These are provided via the following JSON files:

  • dist/asketch/document.asketch.json
  • dist/asketch/page.asketch.json

These can be manually imported into Sketch by downloading html-sketchapp and installing asketch2sketch.sketchplugin.

Once in Sketch, open the "Plugins" menu and select "From *Almost* Sketch to Sketch". Assuming you've run a full build of the style guide via npm test, you should now be able to select the asketch.json files in dist/asketch.

Contributing

Refer to CONTRIBUTING.md.

If you're planning to change the public API, please open a new issue and follow the provided RFC template in the GitHub issue template.

License

MIT.

  • 注释虽然写起来很痛苦, 但对保证代码可读性至关重要. 下面的规则描述了如何注释以及在哪儿注释. 当然也要记住: 注释固然很重要, 但最好的代码本身应该是自文档化. 有意义的类型名和变量名, 要远胜过要用注释解释的含糊不清的名字. 1:使用 // 或 /* */, 统一就好. 解读:个人觉得//会比较方便一点~ 2:在每一个文件开头加入版权公告, 然后是文件内容描述. 解读: 每个文件都应该包含以下

  • Linux kernel coding style 转自https://www.kernel.org/doc/html/latest/process/coding-style.html#linux-kernel-coding-style This is a short document describing the preferred coding style for the linux kern

  • Abstract This paper attempts to raise some issues that are importantfor graduate students to be successful and to get as muchout of the process as possible, and for advisors who wish tohelp their stud

  • 摘自:http://msdn.microsoft.com/en-us/architecture/cc505969.aspx Contents Introduction A-Z Guide to Being an Architect Conclusion Introduction Being an architect isn't just about baffling people with unu

  • Google Style中有关C语言的风格规范 Google 经常会发布一些开源项目,意味着会接受来自其他代码贡献者的代码。但是如果代码贡献者的编程风格与 Google 的不一致,会给代码阅读者和其他代码提交者造成不小的困扰。Google 因此发布了许多语言的编程风格指南, 如C ++样式指南,Objective-C样式指南,Java样式指南,Python样式指南,Shell样式指南,HTML /

  • ? ????   Python : 3.7.0 ??????   OS : Ubuntu 18.04.1 LTS ??????  IDE : PyCharm 2018.2.4 ????? Conda : 4.5.11 ???typesetting : Markdown ? txt(utf-8) 《道德经》原文 "我有三宝持而保之∶一曰慈,二曰俭,三曰不敢为天下先。" ? code """ @Aut

  • Abstract This paper attempts to raise some issues that are importantfor graduate students to be successful and to get as muchout of the process as possible, and for advisors who wish tohelp their stud

 相关资料
  • .seek( time:*, suppressEvents:Boolean ) : * 不改变状态(播放、暂停、方向)的情况下直接跳转到某个时间点。 //跳转到第2秒 myAnimation.seek(2); //跳转到第2秒,并且不阻止期间的函数、事件 myAnimation.seek(2, false); 必须设定时间点 返回self,方便链式设置 .seek()适用于TweenMaxTw

  • .seek( position:*, suppressEvents:Boolean ) : * 不改变状态(播放、暂停、方向)的情况下直接跳转到某个时间点。 //跳转到第2秒 myAnimation.seek(2); //跳转到第2秒,并且不阻止期间的函数、事件 myAnimation.seek(2, false); 必须设定时间点 返回self,方便链式调用。 .seek()适用于Timel

  • 描述 (Description) 此功能移动到文件中的指定位置。 您可以相对于文件的开头(WHENCE = 0),当前位置(WHENCE = 1)或文件末尾(WHENCE = 2)移动。 此函数主要用于固定长度记录,以随机访问文件的特定记录。 对于WHENCE,您可以使用来自Fcntl模块的常量SEEK_SET,SEEK_CUR和SEEK_END(文件的开头,当前位置,文件末尾)。 此函数类似于U

  • 主要内容:tell() 函数,seek()函数在讲解 seek() 函数和 tell() 函数之前,首先来了解一下什么是文件指针。 我们知道,使用 open() 函数打开文件并读取文件中的内容时,总是会从文件的第一个字符(字节)开始读起。那么,有没有办法可以自定指定读取的起始位置呢?答案是肯定,这就需要移动文件指针的位置。 文件指针用于标明文件读写的起始位置。假如把文件看成一个水流,文件中每个数据(以 b 模式打开,每个数据就是一个字节;以普

  • Android Range Seek Bar 是一个搜索条,跟 Android 默认的很相似,但是它可以通过两指进行区域选择,同时还有其他附加功能。

  • Python3 File(文件) 方法 概述 seek() 方法用于移动文件读取指针到指定位置。 语法 seek() 方法语法如下: fileObject.seek(offset[, whence]) 参数 offset -- 开始的偏移量,也就是代表需要移动偏移的字节数 whence:可选,默认值为 0。给offset参数一个定义,表示要从哪个位置开始偏移;0代表从文件开头开始算起,1代表从