Git Product home page Git Product logo

somenage's Introduction

Somenage

A design system for ozeki1 in Typescript and React.

Best suited for static sites like blogs and marketing sites.

Features

  • Renders Semantic HTML5 code validated by W3C.
  • Aligns elements to the typographic grid.

Built on

  • Typescript, for scalability and better code.
  • Emotion, for style objects and functions.
  • Next.js, for static site rendering.
  • Jest, for testing theme, hooks and components.
  • JsDoc, to generate API documentation.

Footnotes

somenage's People

Contributors

osequi avatar

Watchers

 avatar

somenage's Issues

Silent fallbacks

The following problem occurs all the time:

const props = {a: 1}
const defaultProps = {}
const props2 = {...defaultProps, ...props} // => {}

When a function return value / prop is null / empty / undefined things can go out of control.
Make sure there are sane defaults and return types which work in all conditions.

On XState

  • It was made to work with model based testing using Cypress.
  • It's very very complicated. Lots of concepts to learn.

This simple case:

isHomePage
  ? setMenuState("HOMEPAGE")
  : isPortrait
  ? setMenuState("PORTRAIT")
  : setMenuState("LANDSCAPE");

in XState would require transient states and guards.

See https://github.com/osequi/test-cypress for details

Create a cleaner API

For example:

const maxWidth = useMaxWidth({ maxWidth: 25 }); => const maxWidth = useMaxWidth(25);

Figure out type unions

It seems this is not working: export type TTypographicScaleSettings = TLinearScaleSettings | TModularScaleSettings | {};
Later you can't access settings.base or settings.ratio

But this is working: export type TTypographicScaleSettings = TLinearScaleSettings & TModularScaleSettings;
settings.base or settings.ratio are accessible.

The scalability of the settings in the theme

The main idea behind theming is to enforce rules thus keep things uniform.

An example:

/**
 * Defines the default link style.
 */
const defaultLink: TLink = {
  preset: "default",
  colors: {
    default: "default",
    active: "inverted",
    visited: "default",
  },
  settings: {
    default: {
      textDecoration: "underline",
    },
    active: {
      textDecoration: "line-through",
    },
    visited: {
      textDecorationColor: "red",
    },
  },
};

A link can be freely styled through settings when those settings are not present in the theme. When a setting is present in the theme (colors) it should be moved out from settings. This would like to enforce the usage of the same colors across the design system.

For example textDecorationColor: "red" will break the color system.

This strictness might not scale well.

For example, what if we want bold links? Setting fontWeight: 'bold' on deafult would again break the font system. Instead we should use the 'Nimbus Sans Bold' font through a hook. That would result in adding a new section fonts to the already existing colors and settings. And this might not scale freely.

Perhaps an error-prone, totally uniform design system doesn't scales so well.

Move to isNil

useScale(0) was returning null because instead of isNil(points) we had (!points)

Refactor utilities

The following code chunks repeats. It can be refactored into a utility hook.

let queries = {};

  responsiveColumns &&
    responsiveColumns.map((item, index) => {
      const breakpoint = breakpoints[index];
      if (!breakpoint || !breakpoint.name) return null;

      const query = useBreakpoint(breakpoint.name);
      if (!query) return null;

      queries[`${query}`] = {
        gridTemplateColumns: `repeat(${item}, 1fr)`,
      };
    });

  return queries;

How to test 'real' hooks?

useTheme, useMediaQuery from /hooks are real React hooks, or rely on real React hooks. However the whole /hooks folder test environment is set to node.

For now these 'hooks' have their tests commented out, but real testing should be added.

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.