Skip to content

Commit

Permalink
Meta: Don't engage tailwind at the component level.
Browse files Browse the repository at this point in the history
  • Loading branch information
filiphsps committed Sep 24, 2024
1 parent 7bafbb4 commit 16fd8e2
Show file tree
Hide file tree
Showing 43 changed files with 270 additions and 120 deletions.
15 changes: 15 additions & 0 deletions .changeset/violet-rocks-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@nordcom/nordstar-accented': patch
'@nordcom/nordstar-details': patch
'@nordcom/nordstar-heading': patch
'@nordcom/nordstar-button': patch
'@nordcom/nordstar-header': patch
'@nordcom/nordstar-label': patch
'@nordcom/nordstar-card': patch
'@nordcom/nordstar-view': patch
'@nordcom/nordstar': patch
'@nordcom/nordstar-system': patch
'@nordcom/nordstar-input': patch
---

- Don't engage tailwind at the component level.
3 changes: 2 additions & 1 deletion .hintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"overflow: clip",
"overscroll-behavior",
"text-size-adjust",
"user-select"
"user-select",
"-webkit-text-size-adjust"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion packages/components/accented/src/accented.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ const Accented = forwardRef<'span', AccentedProps>(
({ as: Tag = 'span', color = 'default', className, ...props }, ref) => {
return (
<Tag
ref={ref}
{...props}
ref={ref}
className={cn(
'contents',
color === 'foreground' && 'text-foreground',
(color === 'default' || color === 'primary') && 'text-primary',
color === 'secondary' && 'text-secondary',
Expand Down
3 changes: 0 additions & 3 deletions packages/components/accented/src/globals.css

This file was deleted.

2 changes: 0 additions & 2 deletions packages/components/accented/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './globals.css';

import Accented from './accented';

export type { AccentedProps } from './accented';
Expand Down
3 changes: 0 additions & 3 deletions packages/components/button/src/globals.css

This file was deleted.

2 changes: 0 additions & 2 deletions packages/components/button/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './globals.css';

import Button from './button';

export type { ButtonProps } from './button';
Expand Down
3 changes: 0 additions & 3 deletions packages/components/card/src/globals.css

This file was deleted.

2 changes: 0 additions & 2 deletions packages/components/card/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './globals.css';

import Card from './card';

export type { CardDividerProps, CardProps } from './card';
Expand Down
6 changes: 3 additions & 3 deletions packages/components/details/src/details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ const Details = forwardRef<typeof Card, DetailsProps>(({ label, className, child
);
});

Details.displayName = 'Nordstar.Details';

export default Details;
export default Object.assign(Details, {
displayName: 'Nordstar.Details'
});
3 changes: 0 additions & 3 deletions packages/components/details/src/globals.css

This file was deleted.

2 changes: 0 additions & 2 deletions packages/components/details/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './globals.css';

import Details from './details';

export type { DetailsProps } from './details';
Expand Down
3 changes: 0 additions & 3 deletions packages/components/header/src/globals.css

This file was deleted.

6 changes: 3 additions & 3 deletions packages/components/header/src/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Header = ({ sticky = true, className, children, ...props }: HeaderProps) =
as="header"
borderless={true}
className={cn(
'z-10 mb-3 flex min-h-20 w-full items-center justify-center rounded-none border-0 border-none bg-background/95 px-0 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/75 md:h-20',
'[var(--layout-page-width)]:px-0 z-10 mb-3 flex min-h-20 w-full items-center justify-center rounded-none border-0 border-none bg-background/95 px-3 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/75 md:h-20',
sticky &&
'sticky inset-0 bottom-auto z-40 border-0 border-b-2 border-solid border-background-highlight',
className
Expand Down Expand Up @@ -54,7 +54,7 @@ const Logo = forwardRef<'section', HeaderLogoProps>(({ as, className, ...props }
ref={ref}
draggable={false}
className={cn(
'[var(--layout-page-width)]:px-0 px-3 text-lg font-extrabold uppercase *:h-full *:object-contain *:object-left [&>a]:transition-colors [&>a]:hover:text-primary',
'text-lg font-extrabold uppercase *:h-full *:object-contain *:object-left [&>a]:transition-colors [&>a]:hover:text-primary',
className
)}
/>
Expand All @@ -80,7 +80,7 @@ const Menu = forwardRef<'nav', HeaderMenuProps>(({ as, className, overflowShadow
ref={ref}
draggable={false}
className={cn(
'md:overflow-x [var(--layout-page-width)]:px-0 flex w-full touch-auto select-none items-center gap-6 overflow-x-auto scroll-smooth px-3 py-3 md:justify-end',
'md:overflow-x flex w-full touch-auto select-none items-center gap-6 overflow-x-auto scroll-smooth py-3 md:justify-end',
overflowShadow && 'animate-scroll-shadow-inset [animation-timeline:scroll(self_inline)]',
className
)}
Expand Down
2 changes: 0 additions & 2 deletions packages/components/header/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './globals.css';

import Header from './header';

export type { HeaderLogoProps, HeaderMenuLinkProps, HeaderMenuProps, HeaderProps } from './header';
Expand Down
3 changes: 0 additions & 3 deletions packages/components/heading/src/globals.css

This file was deleted.

2 changes: 0 additions & 2 deletions packages/components/heading/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './globals.css';

import Heading from './heading';

export type { HeadingProps } from './heading';
Expand Down
3 changes: 0 additions & 3 deletions packages/components/input/src/globals.css

This file was deleted.

2 changes: 0 additions & 2 deletions packages/components/input/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './globals.css';

import Input from './input';

export type { InputProps } from './input';
Expand Down
4 changes: 2 additions & 2 deletions packages/components/input/src/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const Input = forwardRef<'input' | 'textarea', InputProps<As>>(
'pointer-events-none select-none text-xs font-extrabold uppercase transition-all [transform:translateZ(0)_translateY(0)]',
!placeholder &&
!contents &&
'-mb-2 text-inherit group-first-of-type:-mb-0 group-focus-within:translate-y-0 group-focus-within:text-sm [transform:translateY(.65rem)]'
'-mb-2 text-inherit [transform:translateY(.65rem)] group-first-of-type:-mb-0 group-focus-within:translate-y-0 group-focus-within:text-sm'
)}
data-full-height={!placeholder && !contents}
>
Expand All @@ -168,7 +168,7 @@ const Input = forwardRef<'input' | 'textarea', InputProps<As>>(
ref={ref}
className={cn(
styles.input,
'relative h-full w-full appearance-none border-0 bg-transparent p-0 text-sm leading-none outline-0 placeholder:text-foreground-highlight placeholder:transition-opacity [font-size:inherit] placeholder:[font-size:inherit]',
'relative h-full w-full appearance-none border-0 bg-transparent p-0 text-sm leading-none outline-0 [font-size:inherit] placeholder:text-foreground-highlight placeholder:transition-opacity placeholder:[font-size:inherit]',
label && as !== 'textarea' && 'absolute inset-y-0 h-15 pt-3',
as === 'textarea' && 'h-full min-h-20 leading-normal'
)}
Expand Down
10 changes: 5 additions & 5 deletions packages/components/input/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"baseUrl": "",
"composite": true,
"outDir": "./dist",
"rootDir": "./src",
"typeRoots": ["./node_modules/@types", "./src/@types", "./dist/index.d.ts"]
"outDir": "dist",
"rootDir": "src",
"typeRoots": ["node_modules/@types", "src/@types", "dist/index.d.ts"]
},
"exclude": ["node_modules", "coverage", "dist", "**/*.test.*", "**/*.stories.*"],
"include": ["./src/@types"],
"include": ["src/@types"],
"references": [{ "path": "../../../tsconfig.json" }]
}
3 changes: 0 additions & 3 deletions packages/components/label/src/globals.css

This file was deleted.

2 changes: 0 additions & 2 deletions packages/components/label/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './globals.css';

import Label from './label';

export type { LabelProps } from './label';
Expand Down
3 changes: 0 additions & 3 deletions packages/components/view/src/globals.css

This file was deleted.

2 changes: 0 additions & 2 deletions packages/components/view/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './globals.css';

import View from './view';

export type { ViewProps } from './view';
Expand Down
1 change: 1 addition & 0 deletions packages/core/nordstar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"@types/react-dom": "18.3.0",
"@types/react": "18.3.9",
"autoprefixer": "10.4.20",
"postcss-import": "16.1.0",
"postcss": "8.4.47",
"prettier": "3.3.3",
"react-dom": "18.3.1",
Expand Down
5 changes: 1 addition & 4 deletions packages/core/nordstar/postcss.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@ const path = require('node:path');
const process = require('node:process');

module.exports = {
plugins: [
require('tailwindcss')(path.resolve(path.join(process.cwd().split('/packages')[0], 'tailwind.config.cjs'))),
require('autoprefixer')
]
plugins: [require('postcss-import')(), require('tailwindcss')('tailwind.config.cjs'), require('autoprefixer')]
};
3 changes: 0 additions & 3 deletions packages/core/nordstar/src/globals.css

This file was deleted.

2 changes: 0 additions & 2 deletions packages/core/nordstar/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './globals.css';

// Core
export type {
As,
Expand Down
98 changes: 98 additions & 0 deletions packages/core/nordstar/tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: ['class'],
content: [
'./src/**/*.{ts,tsx}',
//
'./**/@nordcom/**/dist/**/*.{js,jsx}'
],
theme: {
container: {
center: true,
padding: '2rem',
screens: {
'2xl': '1400px'
}
},
extend: {
height: {
15: '3.75rem'
},
brightness: {
65: '.65'
},
transitionProperty: {
colors: 'color, background-color, border-color, text-decoration-color, fill, stroke, filter'
},
transitionDuration: {
DEFAULT: '250ms'
},
fontSize: {
inherit: 'inherit'
},
fontFamily: {
DEFAULT: ['var(--font-sans, var(--font-fallback))', 'sans-serif'],
heading: ['var(--font-heading, var(--font-sans, var(--font-fallback)))', 'sans-serif'],
body: ['var(--font-heading, var(--font-sans, var(--font-fallback)))', 'sans-serif'],
sans: ['var(--font-sans, var(--font-fallback))', 'sans-serif'],
mono: ['var(--font-mono)', 'monospace']
},
fontWeight: {
inherit: 'inherit'
},
colors: {
foreground: {
DEFAULT: 'hsl(var(--color-foreground))',
highlight: 'hsl(var(--color-foreground-highlight))'
},
background: {
DEFAULT: 'hsl(var(--color-background))',
highlight: 'hsl(var(--color-background-highlight))'
},
primary: {
DEFAULT: 'hsl(var(--color-accent-primary))',
foreground: 'hsl(var(--color-accent-primary-foreground))'
},
secondary: {
DEFAULT: 'hsl(var(--color-accent-secondary))',
foreground: 'hsl(var(--color-accent-secondary-foreground))'
}
},
borderWidth: {
1: 'var(--border-width-small, 1px)',
2: 'var(--border-width, 2px)',
4: 'var(--border-width-large, 4px)'
},
strokeWidth: {
1: '0.2rem',
2: '0.25rem',
3: '0.35rem'
},
aspectRatio: {
'3/2': '3 / 2'
},
keyframes: {
'scroll-shadow-inset': {
from: {
shadow: 'inset -10px 0px 10px -10px var(--header-scroll-shadow, rgb(155 155 155 / 0.75));'
},
to: {
shadow: 'inset 10px 0px 10px -10px var(--header-scroll-shadow, rgb(155 155 155 / 0.75));'
}
}
},
animation: {
'accordion-down': 'accordion-down 0.2s ease-out',
'accordion-up': 'accordion-up 0.2s ease-out'
},
overflow: {}
}
},
future: {
hoverOnlyWhenSupported: true
},
corePlugins: {
preflight: false
},
plugins: []
};
10 changes: 10 additions & 0 deletions packages/core/nordstar/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ export default mergeConfig(
}
}
},
css: {
postcss: 'postcss.config.cjs',
transformer: 'postcss',
devSourcemap: true,
modules: {
scopeBehaviour: 'local',
exportGlobals: true,
hashPrefix: 'TEST___'
}
},
plugins: [
codecovVitePlugin({
enableBundleAnalysis: !!process.env.CODECOV_TOKEN,
Expand Down
14 changes: 0 additions & 14 deletions packages/core/nordstar/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@ export default mergeConfig(
test: {
typecheck: {
tsconfig: `${__dirname}/tsconfig.test.json`
},
coverage: {
exclude: [
'__tests__/*.*',
'.vitest/*.*',

'**/__snapshots__/**/*.*',
'**/__tests__/**/*.*',
'**/*.d.*',
'**/*.test.*',
'**/utils/test/**/*.*',
'**/src/**/index.*',
'**/src/**/config/*.*'
]
}
}
})
Expand Down
Loading

0 comments on commit 16fd8e2

Please sign in to comment.