TailwindCSS를 사용하여 대시보드 만들기 - 섹션 2
선결 조건
이 문장은 Create a dashboard with TailwindCSS - Part 1의 연장이기 때문에, 만약 당신이 아직 읽지 않았다면, 당신은 시작하기 전에 한 번 보아야 합니다.
너는 진도를 따라갔니?계속합시다.
스타일 가이드 페이지 만들기
스타일 가이드를 만들려면 NuxtJS 프로젝트의 페이지 폴더로 이동하여 styleguide라는 파일을 추가하는 새 페이지가 필요합니다.vue.
페이지를 만든 후, 나는 메인 제목이 있는 제목을 추가하고, 앉아서 내가 위에 표시하고 싶은 부분을 생각했다.모든 부분에 비슷한 제목과 간격이 있기 때문에 StyleSection이라는 구성 요소를 만들었습니다.모든 vue가 포함됩니다.
그래서 스타일guide.vue 템플릿에는 StyleSection 구성 요소에 대한 참조가 몇 개 있으며, 참조마다 다른 내용이 있습니다.
<template>
  <div>
    <header>
      <h1>Style guide</h1>
    </header>
    <style-section>
      <template slot="title">Colors</template>
      <colors />
    </style-section>
    <style-section>
      <template slot="title">
        <!-- Title: as Gradients, Font Style & Icons -->
      </template>
      <!-- Component: as Gradients, Fonts & Icons -->
    </style-section>
  </div>
</template>
As they'll be only in the style guide page, I've created a folder in components folder named styleguide where I will store each one of them.
<script>
import StyleSection from '~/components/styleguide/StyleSection.vue'
import Colors from '~/components/styleguide/Colors.vue'
/* Import Components */
export default {
  components: {
    StyleSection,
    Colors,
    /* Components imported */
  }
}
</script>
건축부재
이제 새로운 구성 요소와 그 기능을 살펴보자.
  <template>
    <div class="pt-8">
      <header class="pb-6">
        <h3 class="capitalize">
          <slot name="title"></slot>
        </h3>
        <p class="pb-2 border-b border-gray-300 text-gray-700">
          <slot name="title"></slot> for app theme.
        </p>
      </header>
      <slot />
    </div>
  </template>
  <template slot="title">Colors</template>
Now that we have the basis of each section, let's see what each one is about!
이 글은 Tailwind CSS에 새로운 유틸리티를 추가할 가능성을 논의하고 싶습니다. 저는 뒤집기 카드와 같은 변환을 선택하여tailwind 기본 설정에 존재하지 않는 새로운 속성을 추가했습니다. 어떻게 추가하는지 보여 드리겠습니다!
We're going to add a new utility by creating our own plugin, everything I'm going to explain is taken from the official documentation.
우리가 해야 할 첫 번째 일은tailwindcss/plugin을 가져와tailwind의 변수에 저장하는 것입니다.구성js.
  const plugin = require('tailwindcss/plugin')
이러한 속성은 원근, 뒷면 가시성, 값 보존이 있는 변환 스타일 - 3d와 회전 변환입니다.
  plugin(function({ addUtilities }) {
      const newUtilities = {
        '.rotate-y-0': {
          transform: 'rotateY(0deg)'
        },
        '.rotate-y-180': {
          transform: 'rotateY(180deg)'
        },
        '.transform-style-3d': {
          transformStyle: 'preserve-3d'
        },
        '.backface-hidden': {
          backfaceVisibility: 'hidden'
        },
        '.perspective': {
          perspective: '1000px'
        }
      }
      addUtilities(newUtilities, ['group-hover'])
   })
A pseudo-class variant allows you to style elements on hover, focus, and more. Check the multiple variants here.
현재 우리는 클래스를 만들었습니다. 클래스를 사용하여 변환합시다!
색상이라는 구성 요소를 만들었습니다.vue, styleguide 폴더에 있습니다.그 중에서 나는 모든 색깔의 색조 목록을 포함하는 flexbox를 정의했다.
  <template>
    <div>
      <div
        v-for="color in colors"
        :key="color.name"
        class="flex flex-wrap justify-center md:justify-start -mr-4"
      >
        <div v-for="item in color.palette" :key="item.color" class="pr-4 pb-4">
          <!-- Flip Card template -->
        </div>
      </div>
    </div>
  </template>
그것들을 표시하기 위해서 나는 두 개의 대상을 포함하는'색'이라는 그룹을 만들었다. 하나는 원색과 팔레트이고, 다른 하나는 서로 색을 보완하는 데 쓰인다.구조는 다음과 같습니다.
  colors: [
    {
      name: 'primary',
      palette: [
        {
          color: 'bg-primary-50',
          hex: '#e0f3ed',
          name: '50'
        },
        /* Other options */
      ]
    },
    {
      name: 'complementary',
      palette: [
        {
          color: 'bg-complementary-50',
          hex: '#fce5ea',
          name: '50'
        },
        /* Other options */
      ]
    }
  ]
flexbox 용기 안에는 뒤집기 과도가 있는 색카드가 있을 것입니다. 보기에는 다음과 같습니다.
 
 그러기 위해서는 세 가지를 고려해야 한다.
  <div class="group perspective w-28 h-28 cursor-pointer">
    <div class="relative group-hover:rotate-y-180 transform-style-3d transition ease-linear duration-700">
      <div class="card__front">
        <!-- Front Card Content (Show by default) -->
      </div>
      <div :class="item.color" class="card__back">
        <!-- Back Card Content -->
      </div>
    </div>
  </div>
따라서 이 스타일을 제공하기 위해 두 종류의 카드\uufront와 카드\uuback을 정의해야 합니다.
  <style scoped>
  .card__front,
  .card__back {
    @apply backface-hidden absolute top-0 right-0 rounded-lg flex flex-col items-center justify-center shadow-md w-28 h-28;
  }
  .card__front {
    @apply bg-white z-10 rotate-y-0 p-4;
  }
  .card__back {
    @apply rotate-y-180 p-2;
  }
  </style>
 
 이 구성 요소에 대해 TailwindCSS plugin package 는 플러그인을 만들지 않아도 된다는 것을 알려주고 싶습니다.
그것을 사용하려면 로컬에 설치하기만 하면 됩니다.
  npm i tailwindcss-plugins -D
  plugins: [
    require('tailwindcss-plugins/gradients')
  ]
  theme: {
    ...,
    gradients: (theme) => ({
      'primary-45': [
        '45deg',
        theme('colors.primary.700'),
        theme('colors.primary.300')
      ],
      'complementary-45': [
        '45deg',
        theme('colors.complementary.700'),
        theme('colors.complementary.300')
      ],
      'mixed-45': [
        '45deg',
        theme('colors.complementary.300'),
        theme('colors.primary.100')
      ]
    })
  },
  <template>
    <div class="flex flex-wrap -mr-4 md:-mr-6">
      <div
        v-for="item in gradients" :key="item.name"
        class="w-full sm:w-1/2 md:w-56 pr-4 md:pr-6 pb-4"
      >
        <!-- Color composition -->
        <p
          :class="item.gradient /* item.gradient == 'bg-name-gradient' */"
        >{{ item.name }}</p>
      </div>
    </div>
  </template>
 
 이것은 생성된 템플릿과 뷰가 됩니다.
  <template>
    <div class="flex flex-wrap items-stretch justify-start">
      <header
        class="w-full lg:w-auto border-gray-400 pb-6 border-b lg:pb-0 lg:border-b-0 lg:pr-12 lg:border-r"
      >
        <h1>Heading h1</h1>
        <!-- Other Headings -->
      </header>
      <div
        class="w-full lg:max-w-xl border-gray-400 py-6 border-b lg:py-0 lg:border-b-0 lg:px-12 lg:border-r"
      >
        <p>
          Lorem ipsum
          <span class="italic">italic</span>
          <span class="text-primary-900">primary 900</span>
          <span class="underline">underline</span>
          ...
        </p>
        <p class="pt-4 font-bold">
          Font bold lorem ipsum.
        </p>
      </div>
      <p
        class="w-full lg:w-auto border-gray-400 pt-6 lg:pt-0 lg:pl-12 flex flex-col items-center justify-center"
      >
        <span class="text-giant leading-none">Aa</span>
        <span class="text-lg">Source Sans Pro</span>
      </p>
    </div>
  </template>
 
 I'll be expanding this component as I add new icons.
색을 결정해야 하고 우리의 가능성을 보여줄 수 있는 것을 피하기 위해 색 선택기를 만들기로 했습니다.간단하게 말하면, 색상 중 하나를 누르면 ChooseColor 변수가 업데이트되고, fillcurrent 속성이 있는 아이콘이 이 스타일을 적용합니다.
여기서, 나는 이 구성 요소를 당신들에게 보여 드리겠습니다. 왜냐하면 나는 계속하는 과정에서 아이콘을 추가해야 하기 때문에, 아이콘 스타일이라는 클래스를 만들어서 다시 사용할 수 있도록 했습니다.
As always with the styles of TailwindCSS using @apply.
  <template>
    <div :class="choosenColor">
      <ul class="w-full flex flex-wrap items-center pb-4">
        <li><p class="pr-4 pb-2 text-gray-700">Select color</p></li>
        <li v-for="color in colors" :key="color.bg" class="pr-2">
          <button
            :class="color.bg" class="w-6 h-6 rounded-full focus:outline-none"
            :aria-label="'Choose ' + color.text" @click="choosenColor = color.text"
          />
        </li>
      </ul>
      <div class="flex flex-wrap">
        <p class="pb-4 pr-4"><bone class="icon-style" /></p>
        <!-- Other Icons -->
      </div>
    </div>
  </template>
  <script>
  import Bone from '~/components/icons/Bone.vue'
  /* Other Icons */
  export default {
    components: {
      Bone,
      /* Other Icons imported */
    },
    data() {
      return {
        colors: [
          { text: 'text-primary-500', bg: 'bg-primary-500' },
          /* Other options */
        ],
        choosenColor: ''
      }
    }
  }
  </script>
  <style scoped>
  .icon-style {
    @apply bg-white rounded-lg shadow-md p-2 w-12 h-12 fill-current;
  }
  </style>
이것은 우리의 스타일 가이드 페이지입니다.
 
 이 항목을 Heroku에 올렸기 때문에 Cabbage Dashboard 에서 결과를 볼 수 있습니다.💜
새 구성 요소를 추가하고 절차를 설명하지만, 이 시리즈에서 보고 싶은 모든 기능을 실행하도록 요구할 수 있습니다.🥰
저장소를 보려면 다음과 같이 하십시오. https://github.com/Dawntraoz/cabbage
Reference
이 문제에 관하여(TailwindCSS를 사용하여 대시보드 만들기 - 섹션 2), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/dawntraoz/create-a-dashboard-with-tailwindcss-part-2-1m5c텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)