Skip to content

Commit

Permalink
feat: tw
Browse files Browse the repository at this point in the history
  • Loading branch information
jaskang committed Sep 26, 2023
1 parent 895b174 commit f5a6b65
Show file tree
Hide file tree
Showing 90 changed files with 41 additions and 27,579 deletions.
4 changes: 2 additions & 2 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export default defineConfig({
],
resolve: {
alias: {
'@': fileURLToPath(new URL('../../packages/vue/src', import.meta.url)),
'@zonda/vue': fileURLToPath(new URL('../../packages/vue/src/index', import.meta.url)),
// '@': fileURLToPath(new URL('../../packages/vue/src', import.meta.url)),
// '@zonda/vue': fileURLToPath(new URL('../../packages/vue/src/index', import.meta.url)),
},
},
server: {
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@zonda/vue/dist/style.css'
import './index.css'

import {
Expand Down
4 changes: 1 addition & 3 deletions docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"extends": "@jaskang/config/tsconfig.vue.json",
"compilerOptions": {
"paths": {
"@zonda/vue": ["../packages/vue/src"]
}
"paths": {}
},
"include": ["env.d.ts", ".vitepress/**/*"]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"type": "module",
"scripts": {
"dev": "pnpm --filter docs dev",
"start": "pnpm --filter docs dev",
"docs:build": "pnpm --filter docs build",
"docs:preview": "pnpm --filter docs preview",
"build": "pnpm --filter @zonda/vue build"
Expand All @@ -19,7 +20,6 @@
"devDependencies": {
"@jaskang/config": "^2.0.0",
"@jaskang/eslint-config": "^2.0.0",
"@pandacss/dev": "^0.15.1",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.6",
"@tailwindcss/typography": "^0.5.10",
Expand Down
15 changes: 13 additions & 2 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,20 @@
"author": "jaskang",
"license": "MIT",
"type": "module",
"main": "index.js",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist",
"dist/index.css"
],
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./dist/style.css": "./dist/style.css"
},
"scripts": {
"prepare": "panda codegen",
"dev": "vite dev",
"build": "vite build"
},
Expand Down
34 changes: 0 additions & 34 deletions packages/vue/panda.config.ts

This file was deleted.

5 changes: 0 additions & 5 deletions packages/vue/postcss.config.cjs

This file was deleted.

60 changes: 1 addition & 59 deletions packages/vue/src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,45 +52,6 @@ export const Button = defineComponent({
icon: () => VNode
}>,
setup(props, { slots, emit }) {
const cssVars = useColorVars('z-btn', () => {
switch (props.variant) {
case 'solid':
return {
'text-color': 'white',
'bg-color': `${props.color}.500`,
'bg-color-hover': `${props.color}.600`,
'outline-color': `${props.color}.500`,
}
case 'soft':
return {
'text-color': `${props.color}.600`,
'bg-color': `${props.color}.100`,
'bg-color-hover': `${props.color}.200`,
'outline-color': `${props.color}.500`,
}
case 'plain':
return {
'text-color': `${props.color}.600`,
'bg-color-hover': `${props.color}.100`,
'outline-color': `${props.color}.500`,
}
case 'link':
return {
'text-color': `${props.color}.600`,
'outline-color': `${props.color}.500`,
}
default:
return {
'text-color': 'slate.700',
'bg-color': 'white',
'bg-color-hover': 'slate.50',
'border-color': 'slate.300',
'border-color-hover': 'slate.300',
'outline-color': 'primary.500',
}
}
})

const hasIcon = computed(() => !!slots.icon || props.loading)
const onClick = (e: MouseEvent) => {
if (!props.disabled) {
Expand All @@ -99,26 +60,7 @@ export const Button = defineComponent({
}
const cls = computed(() => style(props))
return () => (
<button
style={{
'--btn-size': {
xs: token.var('spacing.row-xs'),
sm: token.var('spacing.row-sm'),
md: token.var('spacing.row-md'),
lg: token.var('spacing.row-lg'),
xl: token.var('spacing.row-xl'),
}[props.size],
}}
class={cx(
cls.value,
css({
color: `${props.color}.500`,
})
)}
type="button"
disabled={props.disabled}
onClick={onClick}
>
<button class={cls.value} type="button" disabled={props.disabled} onClick={onClick}>
{hasIcon.value && (
<i class="z-btn_icon">
{props.loading ? <LoadingIcon class="animate-spin" /> : slots.icon?.()}
Expand Down
11 changes: 10 additions & 1 deletion packages/vue/src/components/Button/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,16 @@ export const style = (props: ButtonInnerProps) => {
pill: props.circle || props.pill,
square: props.circle || props.square,
}),
colorStyle()
colorStyle(),
{
'--btn-size': {
xs: token.var('spacing.row-xs'),
sm: token.var('spacing.row-sm'),
md: token.var('spacing.row-md'),
lg: token.var('spacing.row-lg'),
xl: token.var('spacing.row-xl'),
}[props.size],
}
)
return ret
}
1 change: 0 additions & 1 deletion packages/vue/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import './styles/index.css'

// import './styles/_index.scss'
import type { Plugin } from 'vue'

import { ElSlot } from './components/_pure/ElSlot'
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/src/styles/index.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@layer reset, base, tokens, recipes, utilities;
@layer z-reset, z-base, z-tokens, z-recipes, z-utilities;
12 changes: 6 additions & 6 deletions packages/vue/src/utils/clst.ts → packages/vue/src/utils/tw.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { clsx, type Flat } from 'kotl'

type ClsvValue = string | [string, string]
type TwValue = string | [string, string]

type VariantConfig = {
[key: string]: { true: ClsvValue; false: ClsvValue } | { [key: string]: ClsvValue }
type VariantsObject = {
[key: string]: { true: TwValue; false: TwValue } | { [key: string]: TwValue }
}

type InferVariants<T> = {
[K in keyof T]: keyof T[K] extends 'true' | 'false' ? boolean : keyof T[K]
}

export function clsVariants<T extends VariantConfig>(
export function tw<T extends VariantsObject>(
base: string,
options: {
variants: T
compoundVariants?: Array<Partial<Flat<InferVariants<T>>> & { class: ClsvValue }>
compoundVariants?: Array<Partial<Flat<InferVariants<T>>> & { class: TwValue }>
}
) {
return (v: Flat<InferVariants<T>>) => {
const cls = base.split(' ').map(s => s.trim())
Object.keys(options.variants).forEach(key => {
const value = options.variants[key]
let clsValue: ClsvValue = ''
let clsValue: TwValue = ''
if (value) {
const val = v[key]
if (typeof val === 'boolean') {
Expand Down
34 changes: 0 additions & 34 deletions packages/vue/styled-system/css/conditions.mjs

This file was deleted.

9 changes: 0 additions & 9 deletions packages/vue/styled-system/css/css.d.ts

This file was deleted.

44 changes: 0 additions & 44 deletions packages/vue/styled-system/css/css.mjs

This file was deleted.

6 changes: 0 additions & 6 deletions packages/vue/styled-system/css/cva.d.ts

This file was deleted.

Loading

0 comments on commit f5a6b65

Please sign in to comment.