Giter VIP home page Giter VIP logo

zss's Introduction

📐 ZSS – Sass for design systems

ZSS is a Sass framework that helps you build design systems with configurable design scales.



Documentation

This overview provides an in depth view of all of the available properties/classes in ZSS.

Background

What it does

  • Provides a simple base for your typography.
  • Provides abstractions of common UI patterns, so you can focus on the specific design details.
  • Functional CSS: generates immutable, configurable, and responsive utility classes.
  • Provides a flexible and configurable flexbox grid.
  • Provide compile time checking of your configuration for design smells.

What it doesn’t do

  • No pre-defined colors.
  • Unlike Bootstrap, ZSS does not contain pre-made components or JavaScript.

Principles

ZSS is built on a few principles.

  • Composition over repetition
    The class attribute is perfect for composing your design with multiple classes. It leads to better re-usability of your design and smaller CSS stylesheets.
  • Configurable and optional
    In ZSS, generated utility classes have configurable values. Need an extra value, or don’t like the default values? Just override a variable in your project. Don’t need the button abstraction class? Just don’t import it.
  • Responsiveness
    All utility classes have responsive equivalents, so you can use different values on different screens.
  • Design scales
    ZSS uses scales to limit the number of available values for certain properties, like color and margin.

Setup

Install:

npm install zss --save

After that, import the files you need into your Sass stylesheet.

@import "../node_modules/zss/src/utilities/background-color";

ℹ️ Please note that some utility classes make use of the responsive helper mixins. To make sure ZSS compiles correctly import these before you import the utility classes:

@import "../node_modules/zss/src/helpers/responsive";
@import "../node_modules/zss/src/utilities/margin";

ℹ️ You can use the accompanying file zss.scss as a starting point for your project's stylesheet. It imports all files that are available in ZSS.

Structure

Class names

ZSS uses namespaces, similar to the system CSS Wizardry wrote about.

  • o- prefix for abstract objects.
  • u- prefix for utility classes.

Source order

ZSS advocates importing sources files in the way ITCSS prescribes, with an inverted specificity.

  1. Settings and variables
  2. Mixins and other Sass helpers
  3. Generic: common resets
  4. Base: unclassed HTML and page setup
  5. Abstract objects
  6. Components
  7. Scopes
  8. Theming
  9. Visual classes
  10. Utility classes

Responsive

ZSS uses an @breakpoint suffix to indicate if a class only works on a certain breakpoint, e.g. u-black@md.


How to use

Configuration and variables

All ZSS variables are defined in variables/_zss-defaults.scss. Override them at will in your project.

@import '../node_modules/zss/src/variables/zss-defaults';
@import 'variables/zss-overrides';

Design scales

Variable Explanation
$zss--opacity-scale Limited set of values for opacity utility classes.
$zss--border-radius-scale Limited set of values for border-radius utility classes.
$zss--border-width-scale Limited set of values for border-width classes.
$zss--spacing-scale Limited set of values for margin and padding utility classes.
$zss--type-scale Limited set of values for font-size utility classes.
$zss--line-height-scale Limited set of values for line-height utility classes.
$zss--width--scale Limited set of values for width utility classes.
$zss--width--percentage-scale Limited set of values for width utility classes, in percentages.
$zss--max-width--scale Limited set of values for max-width utility classes.
$zss--height--scale Limited set of values for height utility classes.
$zss--height--percentage-scale Limited set of values for height utility classes, in percentages.

Other variables

Variable Explanation
$zss--colors Sass map with color definitions for text, backgrounds and borders utility classes.
$zss--grid-max-widths Sass map containing the max width of the grid on each breakpoint.
$zss--grid-columns The number of columns a grid row can have.
$zss--grid-gutter The amount of whitespace between grid column.
$zss--breakpoints Sass map containing breakpoint names and screen sizes.
$zss--border-colors Sass map containing color definitions for border utility classes.
$zss--base-font-size Font size used a base for rem values.
$zss--base-line-height Base line-height applied to the BODY element.
$zss--media-margin The margin between the image and text of media objects.

Development checks

ZSS provides compile time checking of the configuration. Import dev/strict if you want to:

  • Check if the design scales are properly ordered.
  • Check if there are any so called design smells, like too many font sizes in your scales.

See the documentation for more details.

Helpers

Helpers are mixins, functions, and similar programmatic constructs in Sass that help with code re-use. ZSS provides these helpers:

  • color: function for accessing pre-defined colors.
  • grid: mixin for generating grid classes.
  • hover: mixin for generating flexible hover effects.
  • responsive: mixin for dealing with responsive declarations.
  • units: functions for dealing with units and values.

Generic

The generic folder contains CSS applied at a global level:

Base

The base folder contains CSS applied to specific elements:

Abstract objects

Objects are classes that define the structure of a common UI pattern, like the popular media object. ZSS provides these objects:

  • button: a gathering of properties most used in buttons.
  • grid: a grid structure to create a layout with rows and columns.
  • list-reset: resets ordered and unordered lists.
  • media: image next to text.

Utility classes

Utility classes have a single responsibility. In other words, they affect the value of just one single CSS property. (This construct is also known as functional CSS.) The most common CSS properties are available in ZSS and are listed in the property index 📇.

Add-ons and tools

These tools and add-ons make working with ZSS even easier.

Third party

Maintainer

zss's People

Contributors

7ochem avatar avanderhoek avatar boudewijn-zicht avatar cynthiameiring avatar erik-zicht avatar hangloozz avatar peterknijff avatar rikvanderkemp avatar wpbenner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

zss's Issues

Replace flex grid with css grid

Provide a simple implementation of the CSS Grid module to replace the flex grid.

  • Move the current flex grid to a separate package, for backwards compatibility.
  • Mark the flex grid as obsolete using @warn
  • Refactor current grid classes to use CSS Grid.
  • Consider extra util classes for columns and rows.

Column classes

CSS Grid is so powerful that ZSS would need to contain an enormous amount of CSS to harness all that power. So I'm thinking of providing just a few basic classes that can be used to setup a quick grid similar to our current grid. (They can even be placed in a separate SCSS file so they're entirely optional.) For custom grids, it's probably best to write a few classes in the project itself.

Possible options:

  • Provide a few classes for an automatic responsive grid. For example, .o-grid--auto--3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } is enough for a responsive grid that has 4 columns on desktop. You don't need to use any extra row or column elements:
<div class="o-grid  o-grid--auto--3">
   <!-- Add cards here -->
</div>
  • Add utility classes to position rows and columns on specific tracks. Something like this:
.o-grid__col--1/5 { grid-column: 1 / 5; }
.o-grid__col--2/end { grid-column: 2 / -1; }
.o-grid__row--2/4 { grid-row: 2 / 4; }

Warnings from ZSS

Are the limits within these checks outdated? Perhaps these days we need more values (we have more devices and screen sizes than before).

Also, at first, I did not have a clue where these warnings during an NPM build were coming from. I Googled them and, of course, did not find anything. Maybe Zicht ZSS should be included in the description somewhere (for instance WARNING [Zicht ZSS]: ...)

And... The link to the details does not exist anymore because we've removed all the release/z.y.x branches.

WARNING: `$zss--spacing-scale` contains more than 8 values.        This is a design smell that should probably be fixed.        More details: https://github.com/zicht/zss/blob/release/2.1.x/errors/too-many-values.md
         on line 47 of node_modules/zss/src/dev/_strict.scss
         from line 143 of stdin

WARNING: $zss--border-radius-scale` contains more than 5 values.        This is a design smell that should probably be fixed.        More details: https://github.com/zicht/zss/blob/release/2.1.x/errors/too-many-values.md
         on line 138 of node_modules/zss/src/dev/_strict.scss
         from line 143 of stdin

Possibility to use column-offsets for the grid

Sometimes there is the need to have a little whitespace on the left, following the flow of the columns. SO it would be handy if something like o-grid__col--offset--1 or o-grid__col--1--offset can be used.

Transition classes

Would like to have several transition classes that work in conjunction with the u-hidden class.

Current behavior:
Toggling the u-hidden class on an element will hide or show it, without any animation.

Requested behavior:
Toggling the u-hidden class on an element that also has a c-transition--slide will hide or show it, with a slide animation.

Perhaps it is possible to combine multiple transitions, i.e. c-transition--slide and c-transition--fade etc...

Some things should be configurable per project, for example how fast the animations should be.

utility background-color uses wrong BEM-notification

The utility color uses: 'u-white'. with one dash, while the utility background-color uses a modifier-style dash: 'u-bg--white'.
Solving this will introduce backwards compatibility issues's, but maybe for a new release version?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.