Giter VIP home page Giter VIP logo

ui-react's Introduction

HEAVILY INCOMPLETE

Do not use this package in production! Almost every commit will be a breaking change.

@solved-ac/ui-react

React component library used by solved.ac

NPM JavaScript Style Guide

Install

yarn add @solved-ac/ui-react @emotion/react @emotion/styled

or, with npm:

npm install --save @solved-ac/ui-react @emotion/react @emotion/styled

Usage

<ThemeProvider theme={solvedThemes.light}>
  <SolvedGlobalStyles />
  <Component />
</ThemeProvider>

Contribute

Contributions are welcome!

License

MIT © shiftpsh

ui-react's People

Contributors

mu-hun avatar ranolp avatar shiftpsh avatar

Stargazers

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

Watchers

 avatar  avatar

ui-react's Issues

storybook 개발 환경 개선 건의

현재 빌드를 위해 두가지의 절차를 거치는게 번거롭게 느껴졌습니다:

  1. 루트 경로에서 microbundle 커맨드를 실행
  2. example 경로로 이동해서 start-storybook 을 실행

개발 환경에서는 프로덕션 빌드를 건너 뛰고 바로 스토리북 개발 서버를 실행하는 사용하는 프로젝트 구조를 사용하면 어떨까요..?

아래와 같이 컴포넌트와 스토리 컴포넌트를 같은 경로에 두면 스토리북 개발 서버에서 개발 중인 컴포넌트의 빌드를 위임을 할 수 있습니다!

❯ ls src/components  
Button.tsx                Button.stories.tsx             Collapse.tsx              Collapse..stories.tsx  // (생략)

`cssVariables`의 반환 타입이 올바르지 않습니다.

export const cssVariables = <
T extends {
readonly [key: string]: string | ((theme: SolvedTheme) => string)
},
P extends string
>(
defaults: T,
prefix: P
): {
vars: { [key in keyof T]: `--solvedac-${string}` }
v: { [key in keyof T]: `var(--solvedac-${P}-${string})` }
styles: (theme: SolvedTheme) => string
} => {

위 부분에서 v의 타입을 정확히 정의하기 위해서는 (MakeKebabCase<T> 같은 타입을 만든 후) `var(--solvedac-${MakeKebabCase<P>}-${string})`와 같이 정의되어야 합니다.

그 이유는 다음과 같습니다.

const v = Object.fromEntries(
Object.entries(vars).map(([k, v]) => [k, `var(${v})`])
) as { [key in keyof T]: `var(--solvedac-${P}-${string})` }

v는 위 코드에 의해 결정되고, 각 값은 vars 오브젝트의 키 k에 대해 `var(${vars[k]})`입니다.

const vars = Object.fromEntries(
names.map((name) => [
name,
`--solvedac-${toCssName(prefix)}-${toCssName(name)}`,
])
) as { [key in keyof T]: `--solvedac-${string}` }

vars는 위 코드에 의해 결정되고, 각 값은 names 배열의 원소 name에 대해 `--solvedac-${toCssName(prefix)}-${toCssName(name)}`입니다.

export const toCssName = (name: string): string =>
name.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).replace(/^-/, '')

toCssName은 위 코드와 같이 정의되고, 사이사이에 낀 알파벳 대문자를 소문자로 바꾸는 역할을 합니다.

따라서, toCssName(prefix)의 타입은 P라고 볼 수 없습니다.
반례로 P = 'exampleValue', name = string일 때 실제 값은 --solvedac-example-value-${string}일 것입니다.

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.