Giter Club home page Giter Club logo

sentro's Introduction

Sentro

lang version_badge license_badge stars

A low-level SCSS library for building and managing token-driven design systems.

Installation

# NPM
npm install @matteusan/sentro --save

# Yarn
yarn add @matteusan/sentro --save

Documentation

  • The documentation for this project is located here.

Showcase

SCSS Input

  • Tokenize your UI while creating an intuitive theming API for your design system.
@use 'path/to/@matteusan/sentro' with (
  $prefix: 'sdb',
  $context: 'theme'
);

:root {
  @include sentro.token-config(
    $primary: (
      'default': #122c53,
      'light': #536b99,
      'dark': #061021,
      'ink': #fff
    ),
    $secondary: (
      'default': #ffac00,
      'light': #ffd77e,
      'dark': #533800,
      'ink': #000
    ),
    $radius: (
      'small': 0.3rem,
      'medium': 0.5rem,
      'large': 0.7rem
    ),
  );
}

.my-button-theme {
  background: sentro.key-create('button-fill', sentro.token-get('secondary'));
  color: sentro.key-create('button-ink', sentro.token-get('secondary-ink'));
  border-color: sentro.key-create('button-border', sentro.token-get('secondary'));
  border-radius: sentro.key-create('button-radius', sentro.token-get('radius-small'));
}

CSS Output

  • Voila!
:root {
  --sdb-theme-primary: #122c53;
  --sdb-theme-primary-light: #536b99;
  --sdb-theme-primary-dark: #061021;
  --sdb-theme-primary-ink: #fff;
  --sdb-theme-secondary: #ffac00;
  --sdb-theme-secondary-light: #ffd77e;
  --sdb-theme-secondary-dark: #533800;
  --sdb-theme-secondary-ink: #000;
  --sdb-theme-radius-small: 0.3rem;
  --sdb-theme-radius-medium: 0.5rem;
  --sdb-theme-radius-large: 0.7rem;
}

.my-button-theme {
    background: var(--sdb-button-fill, var(--sdb-theme-secondary));
    color: var(--sdb-button-ink, var(--sdb-theme-secondary-ink));
    border-color: var(--sdb-button-border, var(--sdb-theme-secondary));
    border-radius: var(--sdb-button-radius, var(--sdb-theme-radius-small));
}

sentro's People

Contributors

matteusan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sentro's Issues

Provide example use case in docs

An example scenario where sentro or its features are convenient/useful may help attract unaware and potential library users. A few short descriptions of what it is about or comparison between similar libraries (if any) is also appreciated.

[FEAT] - Add token and key registry getters.

Suggestion Details
Add a function that retrieves all tokens and keys from registries.

Suggestion Context
This will greatly benefit authoring utility classes based on given tokens/keys.

Possible Implementation
Here's my suggested public API in the context of being used in generating utility classes based on tokens.

@use 'node_modules/@matteusan/sentro' with (
  $prefix: 'hc',
  $context: 'theme'
);

:root {
  @include sentro.token-config(
    // $tokens go here...
  );
}

/// @access private
/// @type map
$_design-tokens: sentro.token-registry-get(); // returns a map of tokens with its corresponding values.

@each $token, $value in $_design-tokens {
  .#{$token}-#{$value} {
     property: $value;
  }
}

I do think having a $targets parameter is useful for only querying tokens with a specific prefix like padding or color.

$_design-tokens: sentro.token-registry-get(('padding', 'color')); 

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.