diff --git a/base/package.json b/base/package.json index 31ccb3b..0b45a6b 100644 --- a/base/package.json +++ b/base/package.json @@ -1,6 +1,6 @@ { "name": "@tesseract-design/web-base", - "version": "0.0.0", + "version": "0.2.0", "files": [ "dist", "src" @@ -63,5 +63,10 @@ }, "typesVersions": { "*": {} + }, + "dependencies": { + "clsx": "^1.2.1", + "tailwind-merge": "^1.14.0", + "tailwindcss": "^3.3.3" } } diff --git a/base/src/index.ts b/base/src/index.ts index 4dc8062..9815d33 100644 --- a/base/src/index.ts +++ b/base/src/index.ts @@ -1,2 +1,4 @@ export * as Button from './button'; export * as TextControl from './text-control'; + +export * as tailwind from './tailwind'; diff --git a/base/src/tailwind.ts b/base/src/tailwind.ts new file mode 100644 index 0000000..fbdb967 --- /dev/null +++ b/base/src/tailwind.ts @@ -0,0 +1,73 @@ +import { clsx } from 'clsx'; +//import { twMerge } from 'tailwind-merge'; +import plugin from 'tailwindcss/plugin'; +export type { PluginCreator } from 'tailwindcss/types/config'; + +export const tw = (...args: Parameters) => clsx(...args); + +export const basePlugin = plugin( + ({ addUtilities, matchUtilities, theme }) => { + matchUtilities( + { + font: (value) => ({ + tabSize: value, + }), + }, + { + values: theme('fontStretch'), + }, + ); + + addUtilities({ + '.linejoin-round': { + 'stroke-linejoin': 'round', + }, + '.linecap-round': { + 'stroke-linecap': 'round', + }, + }); + }, + { + theme: { + extend: { + colors: { + 'current': 'currentcolor', + 'inherit': 'inherit', + 'transparent': 'transparent', + }, + fontFamily: { + inherit: ['inherit'], + }, + fontStretch: { + 'condensed': 'condensed', + 'semi-condensed': 'semi-condensed', + 'expanded': 'expanded', + 'semi-expanded': 'semi-expanded', + 'inherit': 'inherit', + }, + borderRadius: { + inherit: 'inherit', + }, + minWidth: { + 6: '1.5rem', + 10: '2.5rem', + 12: '3rem', + 16: '4rem', + 48: '12rem', + 64: '16rem', + }, + minHeight: { + 6: '1.5rem', + 10: '2.5rem', + 12: '3rem', + 16: '4rem', + 32: '8rem', + 64: '16rem', + }, + strokeWidth: { + 3: '3', + }, + }, + }, + }, +); diff --git a/categories/web/action/react/package.json b/categories/web/action/react/package.json index 022b425..f111e65 100644 --- a/categories/web/action/react/package.json +++ b/categories/web/action/react/package.json @@ -62,8 +62,7 @@ "access": "public" }, "dependencies": { - "@tesseract-design/web-base": "workspace:*", - "clsx": "^1.2.1" + "@tesseract-design/web-base": "workspace:*" }, "types": "./dist/types/index.d.ts", "main": "./dist/cjs/production/index.js", diff --git a/categories/web/action/react/src/components/ActionButton/index.tsx b/categories/web/action/react/src/components/ActionButton/index.tsx index b439498..368d06c 100644 --- a/categories/web/action/react/src/components/ActionButton/index.tsx +++ b/categories/web/action/react/src/components/ActionButton/index.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; -import clsx from 'clsx'; -import { Button } from '@tesseract-design/web-base'; +import { Button, tailwind } from '@tesseract-design/web-base'; + +const { tw } = tailwind; const ActionButtonDerivedElementComponent = 'button' as const; @@ -85,7 +86,7 @@ export const ActionButton = React.forwardRef {children && ( (
0 && 'opacity-0', )} @@ -457,11 +462,11 @@ export const FileSelectBox = React.forwardRef( {children}
( data-testid="label" id={labelId} htmlFor={id} - className={clsx( + className={tw( 'absolute z-[1] w-full top-0.5 left-0 pointer-events-none pl-1 text-xxs font-bold group-focus-within:text-secondary text-primary leading-none bg-negative select-none', { 'sr-only': hiddenLabel, @@ -157,7 +158,7 @@ export const ComboBox = React.forwardRef( inputMode={resultInputMode} list={datalistId} data-testid="input" - className={clsx( + className={tw( 'bg-negative rounded-inherit w-full peer block font-inherit', 'focus:outline-0', 'disabled:opacity-50 disabled:cursor-not-allowed', @@ -191,7 +192,7 @@ export const ComboBox = React.forwardRef( {hint && (
( {indicator && (
diff --git a/categories/web/choice/react/src/components/RadioTickBox/index.tsx b/categories/web/choice/react/src/components/RadioTickBox/index.tsx index a1ed3b7..d72ad93 100644 --- a/categories/web/choice/react/src/components/RadioTickBox/index.tsx +++ b/categories/web/choice/react/src/components/RadioTickBox/index.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import clsx from 'clsx'; import { useFallbackId } from '@modal-sh/react-utils'; import { PluginCreator } from 'tailwindcss/types/config'; diff --git a/categories/web/color/react/package.json b/categories/web/color/react/package.json index f5dce1a..9ef70bd 100644 --- a/categories/web/color/react/package.json +++ b/categories/web/color/react/package.json @@ -64,10 +64,9 @@ "access": "public" }, "dependencies": { - "clsx": "^1.2.1", + "@tesseract-design/web-base": "workspace:*", "color": "^4.2.3", - "color-convert": "^2.0.1", - "tailwindcss": "3.3.2" + "color-convert": "^2.0.1" }, "types": "./dist/types/index.d.ts", "main": "./dist/cjs/production/index.js", diff --git a/categories/web/color/react/src/components/ColorPicker/index.tsx b/categories/web/color/react/src/components/ColorPicker/index.tsx index 5c58e92..1946e1b 100644 --- a/categories/web/color/react/src/components/ColorPicker/index.tsx +++ b/categories/web/color/react/src/components/ColorPicker/index.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; -import clsx from 'clsx'; -import { PluginCreator } from 'tailwindcss/types/config'; +import { tailwind } from '@tesseract-design/web-base'; + +const { tw } = tailwind; const ColorPickerDerivedElementComponent = 'input' as const; @@ -19,7 +20,7 @@ export interface ColorPickerProps extends Omit { +export const colorPickerPlugin: tailwind.PluginCreator = ({ addComponents }) => { addComponents({ '.color-picker': { '&::-webkit-color-swatch-wrapper': { @@ -53,7 +54,7 @@ export const ColorPicker = React.forwardRef< forwardedRef, ) => (
(({ return ( (({ onSelect={copyColor} />