1.1.20 • Published 3 years ago

@hydrogen-design-system/hydrogen.css v1.1.20

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

☀️ Hydrogen

Hydrogen is a utility-first styling tool for creating web interfaces without writing CSS.

It leverages data-attributes to allow the styling of elements, media queries, states, and dark mode right in your markup. Hydrogen offers a comprehensive library of tools and configurations for easy, seamless development. Hydrogen processes your markup and creates a custom CSS file that contains only the code you've used, reducing its own footprint.

Visit the documentation website for details.

🛠️ Basic Usage

Installation

  • run npm install @hydrogen-design-system/hydrogen.css to install Hydrogen
  • run npx h2-init to setup your input/output directories
  • modify your hydrogen.config.json file to match your theme
  • run npx h2-watch to watch your files for changes and compile when a change is detected
  • run npx h2-build when you're ready to deploy to production

Syntax

Hydrogen uses a custom data-attribute syntax for complex styling.

data-h2-UTILITY="MEDIA:DARK:STATE(PARAMETERS)"

An example of a Hydrogen attribute in use would be something like:

data-h2-bg-color="b(primary) b:hover(accent)"

This repository also contains a handy hydrogen.snippets.json file that contains snippet automation for VS Code, enabling auto completion and tab stops.

🏗️ Configuration

You can learn more about Hydrogen's configuration file on the documentation website.

Hydrogen is configured using a hydrogen.config.json file located at the root of your project. The npx h2-init script is designed to create this file for you and prompts for some required information before you can proceed.

Within this configuration file, you can modify many of Hydrogen's utilities to include values that suit your project's needs and theme, including custom media queries, colors, whitespace, and shadows.

🤖 Features

Compression

Hydrogen uses custom scripting to scan your code for data-h2 attributes and then builds a CSS stylesheet that contains only Hydrogen's base and the attributes you've used. No bloat. No duplication. This means that the library in production is extremely small while allowing it to provide a robust set of features and support complex customization.

It also runs Autoprefixer and CSSNano on itself to provide a complete, production ready file.

Utilities

You can learn about utility usage in the documentation, but Hydrogen offers the following utilities:

  • align-content
  • align-items
  • align-self
  • bg-color
  • border
  • container
  • display
  • flex-direction
  • flex-grid and flex-item
  • flex-wrap
  • font-color
  • font-family
  • font-size
  • font-style
  • font-weight
  • gap
  • grid-template-columns
  • grid-template-rows
  • height
  • justify-content
  • layer for z-index control
  • margin
  • offset for positioning control
  • opacity
  • order for flex item order control
  • overflow
  • overlay
  • padding
  • position
  • radius
  • shadow
  • text-align
  • text-decoration
  • text-transform
  • visibility
  • width

States

Along with media queries, Hydrogen offers the ability to modify attributes using the following state keys:

  • :disabled for disabled
  • :focus for focus
  • :hover for hover
  • :active for active

Dark Mode

You can specify unique styles for users who have their browsers/OS set to prefer dark mode or simply want to toggle it on using a class. This can be done by adding :dark to your media query calls:

  • data-h2-bg-color="b(primary)" will set the default background color to primary;
  • data-h2-bg-color="b(primary) b:dark(secondary)" will set the default background color to primary, and if the user prefers dark mode, will set the background to secondary
2.0.0-beta.25

3 years ago

2.0.0-beta.24

3 years ago

2.0.0-beta.9

3 years ago

1.1.20

3 years ago

2.0.0-beta.22

3 years ago

2.0.0-beta.21

3 years ago

2.0.0-beta.20

3 years ago

2.0.0-beta.23

3 years ago

2.0.0-beta.11

3 years ago

2.0.0-beta.10

3 years ago

2.0.0-beta.15

3 years ago

2.0.0-beta.14

3 years ago

2.0.0-beta.13

3 years ago

2.0.0-beta.12

3 years ago

2.0.0-beta.19

3 years ago

2.0.0-beta.18

3 years ago

2.0.0-beta.17

3 years ago

2.0.0-beta.16

3 years ago

2.0.0-beta.8

3 years ago

2.0.0-beta.7

3 years ago

2.0.0-beta.2

3 years ago

2.0.0-beta.1

3 years ago

2.0.0-beta.0

3 years ago

2.0.0-beta.6

3 years ago

2.0.0-beta.5

3 years ago

2.0.0-beta.4

3 years ago

2.0.0-beta.3

3 years ago

1.1.19

3 years ago

1.1.18

3 years ago

1.1.17

3 years ago

1.1.16

4 years ago

1.1.15

4 years ago

1.1.14

4 years ago

1.1.13

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.7

4 years ago

1.0.2

4 years ago

0.0.40

4 years ago

1.0.1

4 years ago

0.0.41

4 years ago

1.0.0

4 years ago

0.0.42

4 years ago

0.0.43

4 years ago

0.0.44

4 years ago

0.0.45

4 years ago

0.0.46

4 years ago

0.0.47

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

0.0.37

4 years ago

0.0.38

4 years ago

0.0.39

4 years ago

0.0.34

4 years ago

0.0.35

4 years ago

0.0.36

4 years ago

0.0.48

4 years ago

0.0.49

4 years ago

0.0.32

4 years ago

0.0.33

4 years ago

0.0.31

4 years ago

0.0.30

4 years ago

0.0.28

4 years ago

0.0.29

4 years ago

0.0.20

4 years ago

0.0.21

4 years ago

0.0.22

4 years ago

0.0.23

4 years ago

0.0.24

4 years ago

0.0.25

4 years ago

0.0.15

4 years ago

0.0.16

4 years ago

0.0.17

4 years ago

0.0.18

4 years ago

0.0.19

4 years ago

0.0.14

4 years ago

0.0.26

4 years ago

0.0.27

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago