New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an example of how to integrate with Deno-Fresh using Twind #298
Comments
I am not using Deno Fresh, but successfully added As we are using Twind, we don't have a global stylesheet and therefore can't use CSS Variables for theming. However, there is still the config object that you can pass to import { defineConfig } from '@twind/core';
import presetAutoprefix from '@twind/preset-autoprefix';
import presetTailwind from '@twind/preset-tailwind';
import { fontFamily } from 'tailwindcss/defaultTheme';
export default defineConfig({
presets: [presetAutoprefix(), presetTailwind()],
theme: {
container: {
center: true,
padding: '2rem',
screens: {
'2xl': '1400px',
},
},
extend: {
colors: {
border: 'hsl(213,9%,23%)',
input: 'hsl(213,9%,23%)',
ring: 'hsl(215,20.2%,65.1%)',
background: 'hsl(213,10%,18%)',
foreground: 'hsl(213,31%,91%)',
primary: {
DEFAULT: 'hsl(197,71%,62%)',
foreground: 'hsl(0,0%,100%)',
},
secondary: {
DEFAULT: 'hsl(213,9%,23%)',
foreground: 'hsl(0,0%,100%)',
},
destructive: {
DEFAULT: 'hsl(0,63%,31%)',
foreground: 'hsl(210,40%,98%)',
},
muted: {
DEFAULT: 'hsl(223,47%,11%)',
foreground: 'hsl(,15.4 16.3%,56.9%)',
},
accent: {
DEFAULT: 'hsl(214,12%,67%)',
foreground: 'hsl(210,40%,98%)',
},
popover: {
DEFAULT: 'hsl(224,71%,4%)',
foreground: 'hsl(215,20.2%,65.1%)',
},
card: {
DEFAULT: 'hsl(224,71%,4%)',
foreground: 'hsl(213,31%,91%)',
},
},
borderRadius: {
extra: '0.8rem',
lg: `0.5rem`,
md: `calc(0.5rem - 2px)`,
sm: 'calc(0.5rem - 4px)',
},
boxShadow: {
'dark-sm': '0 0 0 1px rgba(16, 22, 26, 0.4)',
},
fontFamily: {
sans: ['var(--font-sans)', ...fontFamily.sans],
},
keyframes: {
'accordion-down': {
from: { height: 0 },
to: { height: 'var(--radix-accordion-content-height)' },
},
'accordion-up': {
from: { height: 'var(--radix-accordion-content-height)' },
to: { height: 0 },
},
},
animation: {
'accordion-down': 'accordion-down 0.2s ease-out',
'accordion-up': 'accordion-up 0.2s ease-out',
},
},
},
}); If you wanted to use a dark mode, you could do it this way: import { defineConfig } from '@twind/core';
import presetAutoprefix from '@twind/preset-autoprefix';
import presetTailwind from '@twind/preset-tailwind';
import { fontFamily } from 'tailwindcss/defaultTheme';
export default defineConfig({
presets: [presetAutoprefix(), presetTailwind()],
darkMode: 'class',
darkColor: (section, key, { theme }) => theme(`${section}.dark.${key}`) as ColorValue,
theme: {
container: {
center: true,
padding: '2rem',
screens: {
'2xl': '1400px',
},
},
extend: {
colors: {
border: 'hsl(213,9%,23%)',
input: 'hsl(213,9%,23%)',
ring: 'hsl(215,20.2%,65.1%)',
background: 'hsl(213,10%,18%)',
foreground: 'hsl(213,31%,91%)',
primary: {
DEFAULT: 'hsl(197,71%,62%)',
foreground: 'hsl(0,0%,100%)',
},
secondary: {
DEFAULT: 'hsl(213,9%,23%)',
foreground: 'hsl(0,0%,100%)',
},
destructive: {
DEFAULT: 'hsl(0,63%,31%)',
foreground: 'hsl(210,40%,98%)',
},
muted: {
DEFAULT: 'hsl(223,47%,11%)',
foreground: 'hsl(,15.4 16.3%,56.9%)',
},
accent: {
DEFAULT: 'hsl(214,12%,67%)',
foreground: 'hsl(210,40%,98%)',
},
popover: {
DEFAULT: 'hsl(224,71%,4%)',
foreground: 'hsl(215,20.2%,65.1%)',
},
card: {
DEFAULT: 'hsl(224,71%,4%)',
foreground: 'hsl(213,31%,91%)',
},
dark: {
border: 'hsl(213,9%,23%)',
input: 'hsl(213,9%,23%)',
ring: 'hsl(215,20.2%,65.1%)',
background: 'hsl(213,10%,18%)',
foreground: 'hsl(213,31%,91%)',
primary: {
DEFAULT: 'hsl(197,71%,62%)',
foreground: 'hsl(0,0%,100%)',
},
secondary: {
DEFAULT: 'hsl(213,9%,23%)',
foreground: 'hsl(0,0%,100%)',
},
destructive: {
DEFAULT: 'hsl(0,63%,31%)',
foreground: 'hsl(210,40%,98%)',
},
muted: {
DEFAULT: 'hsl(223,47%,11%)',
foreground: 'hsl(,15.4 16.3%,56.9%)',
},
accent: {
DEFAULT: 'hsl(214,12%,67%)',
foreground: 'hsl(210,40%,98%)',
},
popover: {
DEFAULT: 'hsl(224,71%,4%)',
foreground: 'hsl(215,20.2%,65.1%)',
},
card: {
DEFAULT: 'hsl(224,71%,4%)',
foreground: 'hsl(213,31%,91%)',
},
},
},
borderRadius: {
extra: '0.8rem',
lg: `0.5rem`,
md: `calc(0.5rem - 2px)`,
sm: 'calc(0.5rem - 4px)',
},
boxShadow: {
'dark-sm': '0 0 0 1px rgba(16, 22, 26, 0.4)',
},
fontFamily: {
sans: ['var(--font-sans)', ...fontFamily.sans],
},
keyframes: {
'accordion-down': {
from: { height: 0 },
to: { height: 'var(--radix-accordion-content-height)' },
},
'accordion-up': {
from: { height: 'var(--radix-accordion-content-height)' },
to: { height: 0 },
},
},
animation: {
'accordion-down': 'accordion-down 0.2s ease-out',
'accordion-up': 'accordion-up 0.2s ease-out',
},
},
},
}); The class import { setup } from '@twind/core';
import { config } from './config.ts';
setup(config); You can then import your components using the cli command P.S: Please note that I did not change the color values in dark mode. It was just as an example. Just change the values to match your need. |
A repo to testing shadcn-ui in Fresh: https://github.com/nikogoli/testing-shadcn-ui-in-fresh |
It would be great if the docs added an example of how to set up
shadcn/ui
re-usable components in a Deno-Fresh project that uses Twind.The text was updated successfully, but these errors were encountered: