Move from SCSS to Tailwind
This commit is contained in:
parent
56033e3440
commit
38153e42dc
41 changed files with 856 additions and 736 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -3,3 +3,6 @@ node_modules
|
||||||
|
|
||||||
# OS
|
# OS
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# Build output
|
||||||
|
dist
|
||||||
|
|
|
||||||
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
|
|
@ -1,6 +1,12 @@
|
||||||
{
|
{
|
||||||
"typescript.tsdk": "node_modules/typescript/lib",
|
"typescript.tsdk": "node_modules/typescript/lib",
|
||||||
"typescript.enablePromptUseWorkspaceTsdk": true,
|
"typescript.enablePromptUseWorkspaceTsdk": true,
|
||||||
|
"[json]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[javascript]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
"[typescript]": {
|
"[typescript]": {
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import { defineConfig } from 'astro/config';
|
import { defineConfig } from 'astro/config';
|
||||||
import react from '@astrojs/react';
|
import react from '@astrojs/react';
|
||||||
|
import tailwind from '@astrojs/tailwind';
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
integrations: [react()],
|
integrations: [react(), tailwind()],
|
||||||
});
|
});
|
||||||
1310
package-lock.json
generated
1310
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -5,20 +5,19 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "astro dev",
|
"dev": "astro dev",
|
||||||
"start": "astro dev",
|
|
||||||
"build": "astro build",
|
"build": "astro build",
|
||||||
"preview": "astro preview",
|
"preview": "astro preview",
|
||||||
"astro": "astro"
|
"astro": "astro"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/react": "^1.0.0",
|
"@astrojs/react": "^1.0.0",
|
||||||
|
"@astrojs/tailwind": "^1.0.0",
|
||||||
"@types/react": "^18.0.17",
|
"@types/react": "^18.0.17",
|
||||||
"@types/react-dom": "^18.0.6",
|
"@types/react-dom": "^18.0.6",
|
||||||
"astro": "^1.0.8",
|
"astro": "^1.0.8",
|
||||||
|
"clsx": "^1.2.1",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0"
|
||||||
"sass": "^1.54.5",
|
|
||||||
"typescript-plugin-css-modules": "^3.4.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
src/components/labelled-value.tsx
Normal file
13
src/components/labelled-value.tsx
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
import type { ComponentPropsWithoutRef } from 'react';
|
||||||
|
import clsx from 'clsx';
|
||||||
|
|
||||||
|
interface LabelledValueProps extends ComponentPropsWithoutRef<'div'> {
|
||||||
|
label: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const LabelledValue = ({ label, children, className, ...props }: LabelledValueProps) => (
|
||||||
|
<div className={clsx('text-base space-x-1', className)} {...props}>
|
||||||
|
<span className="font-medium text-gray-700">{label}:</span>
|
||||||
|
<span className="font-normal text-gray-500">{children}</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
8
src/components/section-card.tsx
Normal file
8
src/components/section-card.tsx
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
import clsx from 'clsx';
|
||||||
|
import type { ComponentPropsWithoutRef } from 'react';
|
||||||
|
|
||||||
|
interface SectionCardProps extends ComponentPropsWithoutRef<'div'> {}
|
||||||
|
|
||||||
|
export const SectionCard = ({ className, ...props }: SectionCardProps) => (
|
||||||
|
<div className={clsx('p-8 bg-white rounded-2xl shadow-lg', className)} {...props} />
|
||||||
|
);
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export * from './section-card';
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
.sectionCard {
|
|
||||||
padding: 32px;
|
|
||||||
background: var(--white);
|
|
||||||
border-radius: 16px;
|
|
||||||
box-shadow: 0px 10px 15px -3px rgba(0, 0, 0, 0.1), 0px 4px 6px -4px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
import type { ReactNode } from 'react';
|
|
||||||
import styles from './section-card.module.scss';
|
|
||||||
|
|
||||||
export const SectionCard = ({ children }: { children: ReactNode }) => (
|
|
||||||
<div className={styles.sectionCard}>{children}</div>
|
|
||||||
);
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
.content {
|
|
||||||
font-weight: 400;
|
|
||||||
font-size: 16px;
|
|
||||||
line-height: 28px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
import styles from './content.module.scss';
|
|
||||||
|
|
||||||
export const Content = ({ children }: { children: string }) => <p className={styles.content}>{children}</p>;
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export * from './content';
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export * from './item-description';
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
.itemDescription {
|
|
||||||
font-weight: 400;
|
|
||||||
font-size: 14px;
|
|
||||||
line-height: 20px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
import styles from './item-description.module.scss';
|
|
||||||
|
|
||||||
export const ItemDescription = ({ children }: { children: string }) => (
|
|
||||||
<p className={styles.itemDescription}>{children}</p>
|
|
||||||
);
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export * from './item-subtitle';
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
.itemSubtitle {
|
|
||||||
font-weight: 500;
|
|
||||||
font-size: 14px;
|
|
||||||
line-height: 20px;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
import styles from './item-subtitle.module.scss';
|
|
||||||
|
|
||||||
export const ItemSubtitle = ({ children }: { children: string }) => <p className={styles.itemSubtitle}>{children}</p>;
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export * from './item-title';
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
.itemTitle {
|
|
||||||
font-weight: 800;
|
|
||||||
font-size: 20px;
|
|
||||||
line-height: 28px;
|
|
||||||
color: var(--text-title);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
import styles from './item-Title.module.scss';
|
|
||||||
|
|
||||||
export const ItemTitle = ({ children }: { children: string }) => <h4 className={styles.itemTitle}>{children}</h4>;
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export * from './labelled-value';
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
.labelledValue {
|
|
||||||
font-size: 16px;
|
|
||||||
line-height: 24px;
|
|
||||||
|
|
||||||
& > * + * {
|
|
||||||
margin-left: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
:first-child {
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
:last-child {
|
|
||||||
font-weight: 400;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
import styles from './labelled-value.module.scss';
|
|
||||||
|
|
||||||
export const LabelledValue = ({ label, value }: { label: string; value: string }) => (
|
|
||||||
<div className={styles.labelledValue}>
|
|
||||||
<span>{label}:</span>
|
|
||||||
<span>{value}</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export * from './main-subtitle';
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
.mainSubtitle {
|
|
||||||
font-weight: 500;
|
|
||||||
font-size: 18px;
|
|
||||||
line-height: 28px;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
import styles from './main-subtitle.module.scss';
|
|
||||||
|
|
||||||
export const MainSubtitle = ({ children }: { children: string }) => <h2 className={styles.mainSubtitle}>{children}</h2>;
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export * from './main-title';
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
.mainTitle {
|
|
||||||
font-weight: 800;
|
|
||||||
font-size: 36px;
|
|
||||||
line-height: 40px;
|
|
||||||
color: var(--text-title);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
import styles from './main-title.module.scss';
|
|
||||||
|
|
||||||
export const MainTitle = ({ children }: { children: string }) => <h1 className={styles.mainTitle}>{children}</h1>;
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export * from './section-subtitle';
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
.sectionSubtitle {
|
|
||||||
font-weight: 800;
|
|
||||||
font-size: 18px;
|
|
||||||
line-height: 28px;
|
|
||||||
color: var(--text-title);
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
import styles from './section-subtitle.module.scss';
|
|
||||||
|
|
||||||
export const SectionSubtitle = ({ children }: { children: string }) => (
|
|
||||||
<h3 className={styles.sectionSubtitle}>{children}</h3>
|
|
||||||
);
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export * from './section-title';
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
.sectionTitle {
|
|
||||||
font-weight: 800;
|
|
||||||
font-size: 32px;
|
|
||||||
line-height: 40px;
|
|
||||||
color: var(--text-title);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
import styles from './section-title.module.scss';
|
|
||||||
|
|
||||||
export const SectionTitle = ({ children }: { children: string }) => <h2 className={styles.sectionTitle}>{children}</h2>;
|
|
||||||
47
src/components/typograpy.tsx
Normal file
47
src/components/typograpy.tsx
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
import type { ComponentPropsWithoutRef } from 'react';
|
||||||
|
import clsx from 'clsx';
|
||||||
|
|
||||||
|
type TypographyVariant =
|
||||||
|
| 'item-title'
|
||||||
|
| 'item-subtitle'
|
||||||
|
| 'tile-title'
|
||||||
|
| 'tile-subtitle'
|
||||||
|
| 'main-title'
|
||||||
|
| 'main-subtitle'
|
||||||
|
| 'section-title'
|
||||||
|
| 'section-subtitle'
|
||||||
|
| 'paragraph';
|
||||||
|
|
||||||
|
interface TypographyProps extends ComponentPropsWithoutRef<'div'> {
|
||||||
|
variant?: TypographyVariant;
|
||||||
|
}
|
||||||
|
|
||||||
|
const variantToElement = {
|
||||||
|
'main-title': 'h1',
|
||||||
|
'main-subtitle': 'h2',
|
||||||
|
'section-title': 'h2',
|
||||||
|
'section-subtitle': 'h3',
|
||||||
|
'item-title': 'h3',
|
||||||
|
'item-subtitle': 'p',
|
||||||
|
'tile-title': 'h4',
|
||||||
|
'tile-subtitle': 'p',
|
||||||
|
paragraph: 'p',
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
const variantToClassName = {
|
||||||
|
'main-title': 'text-4xl font-extrabold text-gray-900',
|
||||||
|
'main-subtitle': 'text-lg font-medium text-gray-700',
|
||||||
|
'section-title': 'text-3xl font-extrabold text-gray-900',
|
||||||
|
'section-subtitle': 'text-lg font-extrabold text-gray-900',
|
||||||
|
'item-title': 'text-xl font-extrabold text-gray-900',
|
||||||
|
'item-subtitle': 'text-md font-medium text-gray-700',
|
||||||
|
'tile-title': 'text-sm font-medium text-gray-700',
|
||||||
|
'tile-subtitle': 'text-sm font-normal text-gray-500',
|
||||||
|
paragraph: 'text-base leading-relaxed font-normal text-gray-500',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Typography = ({ variant = 'paragraph', className, ...props }: TypographyProps) => {
|
||||||
|
const Element = variantToElement[variant];
|
||||||
|
|
||||||
|
return <Element className={clsx(variantToClassName[variant], className)} {...props} />;
|
||||||
|
};
|
||||||
|
|
@ -1,13 +1,7 @@
|
||||||
---
|
---
|
||||||
import { SectionCard } from '../components/section-card';
|
import { SectionCard } from '../components/section-card';
|
||||||
import { SectionTitle } from '../components/typography/section-title';
|
import { Typography } from '../components/typograpy';
|
||||||
import { SectionSubtitle } from '../components/typography/section-subtitle';
|
import { LabelledValue } from '../components/labelled-value';
|
||||||
import { ItemTitle } from '../components/typography/item-title';
|
|
||||||
import { ItemSubtitle } from '../components/typography/item-subtitle';
|
|
||||||
import { Content } from '../components/typography/content';
|
|
||||||
import { ItemDescription } from '../components/typography/item-description';
|
|
||||||
import { MainTitle } from '../components/typography/main-title';
|
|
||||||
import { LabelledValue } from '../components/typography/labelled-value';
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
@ -19,35 +13,20 @@ import { LabelledValue } from '../components/typography/labelled-value';
|
||||||
<meta name="generator" content={Astro.generator} />
|
<meta name="generator" content={Astro.generator} />
|
||||||
<title>Welcome to Astro</title>
|
<title>Welcome to Astro</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body class="bg-gray-50">
|
||||||
<main>
|
<main>
|
||||||
<SectionCard>
|
<SectionCard>
|
||||||
<MainTitle>Main title</MainTitle>
|
<Typography variant="main-title">Main title</Typography>
|
||||||
<SectionTitle>Section title</SectionTitle>
|
<Typography variant="main-subtitle">Main subtitle</Typography>
|
||||||
<SectionSubtitle>Section subtitle</SectionSubtitle>
|
<Typography variant="section-title">Section title</Typography>
|
||||||
<ItemTitle>Item title</ItemTitle>
|
<Typography variant="section-subtitle">Section subtitle</Typography>
|
||||||
<ItemSubtitle>Item subtitle</ItemSubtitle>
|
<Typography variant="item-title">Item title</Typography>
|
||||||
<ItemDescription>Item description</ItemDescription>
|
<Typography variant="item-subtitle">Item subtitle</Typography>
|
||||||
<Content>Content</Content>
|
<Typography variant="tile-title">Tile title</Typography>
|
||||||
<LabelledValue label="Phone" value="+48 604 343 212" />
|
<Typography variant="tile-subtitle">Tile subtitle</Typography>
|
||||||
|
<Typography variant="paragraph">Paragraph</Typography>
|
||||||
|
<LabelledValue label="Phone">+48 604 343 212</LabelledValue>
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
</main>
|
</main>
|
||||||
<style>
|
|
||||||
:root {
|
|
||||||
--text-title: #111827;
|
|
||||||
--text-primary: #374151;
|
|
||||||
--text-secondary: #6b7280;
|
|
||||||
--white: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
html {
|
|
||||||
font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
|
|
||||||
'Segoe UI Symbol';
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
16
tailwind.config.cjs
Normal file
16
tailwind.config.cjs
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
const colors = require('tailwindcss/colors');
|
||||||
|
|
||||||
|
/** @type {import('tailwindcss').Config} */
|
||||||
|
module.exports = {
|
||||||
|
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
|
||||||
|
theme: {
|
||||||
|
colors: {
|
||||||
|
transparent: 'transparent',
|
||||||
|
current: 'currentColor',
|
||||||
|
white: colors.white,
|
||||||
|
primary: colors.indigo,
|
||||||
|
gray: colors.gray,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
};
|
||||||
|
|
@ -28,8 +28,6 @@
|
||||||
// Force the usage of the indexed syntax to access fields declared using an index signature.
|
// Force the usage of the indexed syntax to access fields declared using an index signature.
|
||||||
"noUncheckedIndexedAccess": true,
|
"noUncheckedIndexedAccess": true,
|
||||||
// Report an error when the value `undefined` is given to an optional property that doesn't specify `undefined` as a valid value.
|
// Report an error when the value `undefined` is given to an optional property that doesn't specify `undefined` as a valid value.
|
||||||
"exactOptionalPropertyTypes": true,
|
"exactOptionalPropertyTypes": true
|
||||||
// Enable intellisense for imports from CSS Modules.
|
|
||||||
"plugins": [{ "name": "typescript-plugin-css-modules" }]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue