GithubHelp home page GithubHelp logo

text_component's Introduction

text_component

ease apply css on text with Tailwind and Typescript

사용예시

import text from "./text-alltags";

<text.p variant="large / exBold / accent" value="문자 입력" />

위와 같이 입력시 다음과 같이 출력됩니다.

<p class="text-base font-extrabold text-rose-400">테일윈드 사용 시</p>

사용방법 - 주요 코드는 text-alltag.tsx에 모두 포함되어있습니다.

  • text는 object로써 React에서 지원하는 모든 element를 호출할 수 있습니다
  • variant 값에 "(크기) / (굵기) / (색상)" 의 순서로 넣어 tailwind를(class를) 적용합니다.
  • variant 에 값을 입력하는 경우 typescript 덕분에 입력할수 있는 모든 경우의 수를 바로 확인할 수 있습니다.
  • variant 는 디폴트 값을 지정할 수 있고 다음과 같이 작성할 수 있습니다.
<t.div variant="- / * / " value="디폴트 값을 활용하면 더 깔끔합니다" />
<t.div variant=" /  / " value="모두 빈문자열로 지정한 경우" />

초기 세팅하기

  1. text-alltag.tsxvaiants 값과 SEPERATOR 필요에 따라 수정하여 세팅할 수 있습니다.
const SEPERATOR = " / ";
const variants = {
  [SIZE]: {
    [DEFAULT]: ["base", "-"],
    exSmall: "text-xs",
    small: "text-sm",
    base: "text-base",
    large: "text-lg",
    exLarge: "text-xl",
  },
  [WEIGHT]: {
    [DEFAULT]: ["medium", "*"],
    light: "font-light",
    normal: "font-normal",
    medium: "font-medium",
    semibold: "font-semibold",
    bold: "font-bold",
    exBold: "font-extrabold",
  },
  [COLOR]: {
    [DEFAULT]: ["primary", ""],
    primary: "text-emerald-600",
    secondary: "text-amber-400",
    accent: "text-rose-400",
  },
} as const;
  1. 필요한 곳에 호출하여 사용하면 됩니다.
import t from "./text-alltags";

    <t.p variant="- / exBold / accent" value="타입스크립트 사용 시" />
    <t.div variant="large / * / " value="좀더 직관적으로" />
    <t.article
      variant="base / medium / secondary"
      value="class를 전달하는 방법입니다."
    />
    <t.span
      variant="exLarge / * / "
      className="text-justify"
      value="타입스크립트 덕분에 자동완성 되는 부분이 인상적이었고"
    />
    <t.a
      variant="large / bold / "
      value="명확하게 텍스트를 꾸미는 로직임을 알 수 있어 좋았습니다."
    />

text_component's People

Contributors

obov avatar

Stargazers

Roman avatar HaeRhee avatar HyeokJin_Kim avatar

Watchers

 avatar

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.