Skip to content
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

[bug]: tailwind.config.ts malformed after installing components #4841

Open
2 tasks done
niyrme opened this issue Sep 13, 2024 · 3 comments
Open
2 tasks done

[bug]: tailwind.config.ts malformed after installing components #4841

niyrme opened this issue Sep 13, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@niyrme
Copy link

niyrme commented Sep 13, 2024

Describe the bug

after a clean project setup I added many of the shadcn components and the resulting tailwind.config.ts file was slightly malformed.

  • theme.extend.fontFamily has some escaped newlines (and I'm not sure but 'Inter "' as a font also looks a bit wrong)
  • (not that big of a deal, but I'll list it anyway) config was created with mixed spaces and tabs
import type { Config } from "tailwindcss";

export default {
    darkMode: ["class"],
    content: ["./app/**/{**,.client,.server}/**/*.{js,jsx,ts,tsx}"],
  theme: {
  	extend: {
  		fontFamily: {
  			sans: [\\n          'Inter"',\\n          "ui-sans-serif",\\n          "system-ui",\\n          "sans-serif",\\n          'Apple Color Emoji"',\\n          'Segoe UI Emoji"',\\n          'Segoe UI Symbol"',\\n          'Noto Color Emoji"',\\n        ]
  		},
  		borderRadius: {
  			lg: 'var(--radius)',
  			md: 'calc(var(--radius) - 2px)',
  			sm: 'calc(var(--radius) - 4px)'
  		},
  		colors: {
  			background: 'hsl(var(--background))',
  			foreground: 'hsl(var(--foreground))',
  			card: {
  				DEFAULT: 'hsl(var(--card))',
  				foreground: 'hsl(var(--card-foreground))'
  			},
  			popover: {
  				DEFAULT: 'hsl(var(--popover))',
  				foreground: 'hsl(var(--popover-foreground))'
  			},
  			primary: {
  				DEFAULT: 'hsl(var(--primary))',
  				foreground: 'hsl(var(--primary-foreground))'
  			},
  			secondary: {
  				DEFAULT: 'hsl(var(--secondary))',
  				foreground: 'hsl(var(--secondary-foreground))'
  			},
  			muted: {
  				DEFAULT: 'hsl(var(--muted))',
  				foreground: 'hsl(var(--muted-foreground))'
  			},
  			accent: {
  				DEFAULT: 'hsl(var(--accent))',
  				foreground: 'hsl(var(--accent-foreground))'
  			},
  			destructive: {
  				DEFAULT: 'hsl(var(--destructive))',
  				foreground: 'hsl(var(--destructive-foreground))'
  			},
  			border: 'hsl(var(--border))',
  			input: 'hsl(var(--input))',
  			ring: 'hsl(var(--ring))',
  			chart: {
  				'1': 'hsl(var(--chart-1))',
  				'2': 'hsl(var(--chart-2))',
  				'3': 'hsl(var(--chart-3))',
  				'4': 'hsl(var(--chart-4))',
  				'5': 'hsl(var(--chart-5))'
  			}
  		},
  		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'
  		}
  	}
  },
  plugins: [require("tailwindcss-animate")],
} satisfies Config;

Affected component/components

can't say for sure if it's just one, or a combination of many

How to reproduce

  1. Create remix app from template npx [email protected]
    1.1. name:
    1.2. git repository: no
    1.3. "install dependencies": yes
  2. npx [email protected] init
    2.1. style: default
    2.2. base color: slate
    2.3. css variables: yes
  3. add components (happens both inline and interactive)
    3.1. npx [email protected] add accordion alert-dialog avatar badge button calendar card carousel checkbox dialog drawer input input-otp label pagination progress radio-group scroll-area select separator sheet skeleton slider switch table tabs textarea toast toggle toggle-group tooltip
    3.2. skip/decline both button and toggle overwrite messages

Codesandbox/StackBlitz link

https://codesandbox.io/p/devbox/43jndj

Logs

No response

System Info

OS: Windows 10 Pro x64; Version 22H2; Build 19045.4894
Bun 1.1.27-canary.33+6faf657e3
`npx shadcn@latest --version` is `2.0.3` (pinned in reproduction)
`npx create-remix@latest --version` is `2.11.2` (pinned in reproduction)

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@niyrme niyrme added the bug Something isn't working label Sep 13, 2024
@hinsxd
Copy link

hinsxd commented Sep 14, 2024

I have pinpointed the issue to be function parseValue(node: any): any reading assuming the wrong type and reading the wrong field.

I thought I fixed the problem but it seems that if the AST node are treated as correct types, parsing the object first is not a viable option because it cannot handle spread syntax. The only way would be traverse through the AST and replace the value one by one.

WIP: #4851

@cosn
Copy link

cosn commented Sep 18, 2024

+1 to fixing this, but the other, larger issue I've faced is that after fixing this and following the Remix install steps, I get the following error when trying to build:

app/root.tsx (10:7): "default" is not exported by "app/tailwind.css", imported by "app/root.tsx".
file: my-app/app/root.tsx:10:7

 8: import type { LinksFunction } from "@remix-run/node";
 9:
10: import styles from "./tailwind.css";
           ^
11:
12: export const links: LinksFunction = () => [

Anyone else encounter this? The error is on a pure vanilla Remix project and fresh shadcn init.

@cosn
Copy link

cosn commented Sep 18, 2024

Figured it out, the issue is taht the import should be:

import styles from "./tailwind.css?url";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants