From 560222da7936d3473cc0738f7b7bc2743e707421 Mon Sep 17 00:00:00 2001 From: jaskang Date: Fri, 15 Sep 2023 16:31:56 +0800 Subject: [PATCH] feat: css --- docs/.vitepress/config.ts | 8 +++++ src/components/Button/button.css | 50 +++++++++++++++++--------------- src/components/Button/index.tsx | 10 +++---- vite.config.ts | 6 ++++ 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index e8e86a22..7879898f 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -63,6 +63,14 @@ export default defineConfig({ }, title: 'Elenext', vite: { + css: { + transformer: 'lightningcss', + lightningcss: { + drafts: { + nesting: true, + }, + }, + }, plugins: [ Inspect(), vueJsx(), diff --git a/src/components/Button/button.css b/src/components/Button/button.css index 6bbccb8e..8762eb4d 100644 --- a/src/components/Button/button.css +++ b/src/components/Button/button.css @@ -1,4 +1,4 @@ -:where(.z-btn) { +.z-btn { --z-btn-text-color: inherit; --z-btn-bg-color: #fff; --z-btn-border-color: #fff; @@ -25,6 +25,22 @@ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; + &:enabled { + cursor: pointer; + &:hover { + background-color: var(--z-btn-bg-color-hover); + border-color: var(--z-btn-border-color-hover); + } + &:focus-visible { + outline: var(--z-btn-outline-color) solid 2px; + } + } + + &:disabled { + cursor: not-allowed; + opacity: 0.5; + } + &.z-btn_icon { display: block; width: 1em; @@ -42,52 +58,38 @@ align-items: center; justify-content: center; } - - &:enabled { - cursor: pointer; - &:hover { - background-color: var(--z-btn-bg-color-hover); - border-color: var(--z-btn-border-color-hover); - } - &:focus-visible { - outline: var(--z-btn-outline-color) solid 2px; - } - } - - &:disabled { - cursor: not-allowed; - opacity: 0.5; - } } /* 'default' | 'solid' | 'soft' | 'plain' | 'link' */ -:where(.z-btn) { +.z-btn { &.z-btn-default { box-shadow: var(--shadow-sm); border: 1px solid var(--z-btn-border-color); } - &.z-btn-outline { - border: 1px solid var(--z-btn-border-color); - } &.z-btn-solid { - box-shadow: var(--shadow-sm); color: #fff; + box-shadow: var(--shadow-sm); + } + &.z-btn-outline { + border: 1px solid var(--z-btn-border-color); } + &.z-btn-soft { box-shadow: var(--shadow-sm); } + &.z-btn-plain { } &.z-btn-link { &:enabled:hover { - text-decoration: underline solid green 2px; + text-decoration: underline solid var(--z-btn-text-color) 2px; text-underline-offset: 4px; } } } -:where(.z-btn) { +.z-btn { &.z-btn--xs { --z-btn-h: calc(1.75rem + 2px); font-size: 0.75rem; diff --git a/src/components/Button/index.tsx b/src/components/Button/index.tsx index 10c42a28..b6d5cbaf 100644 --- a/src/components/Button/index.tsx +++ b/src/components/Button/index.tsx @@ -1,4 +1,4 @@ -// import './button.css' +import './button.css' import { type ComponentObjectPropsOptions, @@ -94,11 +94,11 @@ export const Button = defineComponent({ } default: return { - 'text-color': 'gray.700', + 'text-color': 'slate.700', 'bg-color': 'white', 'bg-color-hover': 'slate.50', - 'border-color': 'gray.300', - 'border-color-hover': 'gray.300', + 'border-color': 'slate.300', + 'border-color-hover': 'slate.300', 'outline-color': `primary.500`, } } @@ -110,7 +110,6 @@ export const Button = defineComponent({ emit('click', e) } } - const css = computed(()=>cssName(props.color,cssVars.value)) return () => (