question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Description

This issue takes into account issues raised on:

Introduction

Theming is a crucial part of web applications, it has been around for decades now and only expected to grow as apps become more complex, increase in scopes and the types of devices increase.

It is important that we address themes and provide flexibility for users so that they can build powerful, accessible and immersive UI and UX for it’s users.

There are multiple types of themes:

  • Standard - A configuration of key / values that could be replaced (as seen on Tailwind)
  • Runtime - JIT focused, changed on demand on the runtime

A (fairly) new standard has emerged from the Design Tokens Community Group (DTCG) that introduces a new specification for design tokens to unify and standardize how they are consumed. This isolates design tokens from a “theme”, where these work separately from each other and a theme becomes a semantic feature.

Design tokens in Master

Currently Master does provide a lot of configuration for styling, while this is starting point, it can be expanded upon greatly. I propose that we incorporate design tokens directly into Master (please refer to design token specification for further documentation / information about it).

Demonstration

design.tokens

{
  "majestic magenta": {
    "$type": "color",
    "$value": "#ff00ff",
    "$description": "The background color for buttons in their normal state."
  },
  "brand": {
    "color": {
      "$type": "color",
      "acid green": {
        "$value": "#00ff66"
      },
      "hot pink": {
        "$value": "#dd22cc"
      }
    },
    "typeface": {
      "$type": "fontFamily",
      "primary": {
        "$value": "Comic Sans MS"
      },
      "secondary": {
        "$value": "Times New Roman"
      }
    }
  },
  "shadow-token": {
    "$type": "shadow",
    "$value": {
      "color": "#00000088",
      "offsetX": "0.5rem",
      "offsetY": "0.5rem",
      "blur": "1.5rem",
      "spread": "0rem"
    }
  }
}

master.css.js or master.css.ts

import { transformDesignTokens } from '@master/css';
import tokens from './design.tokens';

const config = {
  tokens: transformDesignTokens(tokens),
  // Other config
};

export default config;

The transformed JSON would look similar to:

const tokens = {
  "majestic-magenta": "#ff00ff",
  brand: {
    color: {
      "acid-green": "#00ff66",
      "hot-pink": "#dd22cc",
    },
    typeface: {
      primary: "Comic Sans MS",
      secondary: "Times New Roman",
    },
  },
  // Semantic Class in Master
  "shadow-token": "0.5rem|0.5rem|1.5rem|0|#00000088",
};

Usage without Themes

<div class='bg:majestic-magenta'>Block 1</div>
<div class='bg:brand-color-acid-green'>Block 2</div>

This issue is open for comments should anyone have any concerns or ideas on how this maybe improved.

Currently, I’m working with @1Aron to create a suitable API to bring “theming” into scope with the design tokens, as more thought needs to go into that.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ansarizafarcommented, Sep 30, 2022

I think we should use Javascript Object for defining tokens. JSON looks bad. It would be great If we can also use Master CSS color palette in design tokens.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Deep Dive into Twenty Twenty-Two and WordPress Block ...
Twenty Twenty-Two is the default block theme being introduced with WordPress 5.9. Check out all its key features in this in-depth guide.
Read more >
WordPress Themes & Website Templates from ThemeForest
Discover 1000s of premium WordPress themes & website templates, including multipurpose and responsive Bootstrap templates, email templates & HTML templates.
Read more >
files-community/Custom-themes - GitHub
Custom-themes. Starting in v2.1.2, we bundled a collection of themes with Files. You can still create your own themes and use them in...
Read more >
Jamstack Themes
The most popular list of themes and starters for Jamstack sites. Over 386 free static site generator themes for Hugo, Gatsby, Jekyll, Gridsome...
Read more >
Themes | Oh My Posh
Themes · 1_shell​ · M365Princess​ · agnoster.minimal​ · agnoster​ · agnosterplus​ · aliens​ · amro​ · atomic​.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found