Skip to content

Commit 6ee8f2f

Browse files
committed
Migrate home styles to vanilla-extract
1 parent ee57f67 commit 6ee8f2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1239
-968
lines changed

config/webpackDefaults.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { DefinePlugin, Configuration } from 'webpack'
2+
import { VanillaExtractPlugin } from '@vanilla-extract/webpack-plugin'
23
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
34
import { getMode, getPath } from './utils'
45
import merge from 'webpack-merge'
@@ -13,7 +14,12 @@ export function webpackDefaults(config: Configuration): Configuration {
1314
mode,
1415
devtool: isProduction ? 'source-map' : 'inline-source-map',
1516
module: {
16-
rules: [tsRule(), cssRule(isWeb), fileRule(isWeb)],
17+
rules: [
18+
tsRule(),
19+
vanillaExtractRule(),
20+
cssRule(isWeb),
21+
fileRule(isWeb),
22+
],
1723
},
1824
resolve: {
1925
extensions: ['.tsx', '.ts', '.js', '.json'],
@@ -22,6 +28,7 @@ export function webpackDefaults(config: Configuration): Configuration {
2228
},
2329
},
2430
plugins: [
31+
new VanillaExtractPlugin(),
2532
new MiniCssExtractPlugin(
2633
isProduction
2734
? {
@@ -54,7 +61,7 @@ function tsRule() {
5461
},
5562
},
5663
],
57-
exclude: /node_modules/,
64+
exclude: [/node_modules/, /\.css\.ts$/i],
5865
}
5966
}
6067

@@ -84,6 +91,22 @@ function cssRule(isWeb: boolean) {
8491
},
8592
{ use: nyancssLoaders },
8693
],
94+
exclude: [/\.vanilla\.css$/i],
95+
}
96+
}
97+
98+
function vanillaExtractRule() {
99+
return {
100+
test: /\.vanilla\.css$/i, // Targets only CSS files generated by vanilla-extract
101+
use: [
102+
MiniCssExtractPlugin.loader,
103+
{
104+
loader: require.resolve('css-loader'),
105+
options: {
106+
url: false, // Required as image imports should be handled via JS/TS import statements
107+
},
108+
},
109+
],
87110
}
88111
}
89112

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@
3535
"@types/webpack-hot-middleware": "^2.25.6",
3636
"@types/webpack-node-externals": "^2.5.3",
3737
"@typesaurus/preact": "6.0.0-alpha.4",
38+
"@vanilla-extract/css": "^1.9.2",
39+
"@vanilla-extract/webpack-plugin": "^2.2.0",
3840
"assets-webpack-plugin": "^7.1.1",
3941
"body-parser": "^1.19.0",
42+
"classnames": "^2.3.2",
4043
"copy-webpack-plugin": "^11.0.0",
4144
"cors": "^2.8.5",
4245
"css-loader": "^6.7.3",
@@ -71,6 +74,7 @@
7174
"tsconfig-paths": "^4.1.1",
7275
"tsconfig-paths-webpack-plugin": "^4.0.0",
7376
"tslint": "~6.1.3",
77+
"typedoc": "^0.23.23",
7478
"typeroo": "^0.9.0",
7579
"typesaurus": "10.0.0-alpha.41",
7680
"typescript": "^4.9.4",

src/types/assets.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
declare module '*.png' {
2+
const url: string
3+
export default url
4+
}
5+
6+
declare module '*.jpg' {
7+
const url: string
8+
export default url
9+
}
10+
11+
declare module '*.svg' {
12+
const url: string
13+
export default url
14+
}

src/ui/screens/Docs/Doc/JSDoc/Issue/index.tsx renamed to src/ui/components/DocLinks/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { h } from 'preact'
22
import { useContext } from 'preact/hooks'
3-
import { Link } from '~/ui/components/Home/style.css'
43
import { RouterContext, RouterLink } from '~/ui/router'
54
import { bugTemplateText, docIssueTemplateText } from './templateText'
5+
import * as styles from './styles.css'
66

7-
export default function Issue() {
7+
export const DocLinks = () => {
88
const { location } = useContext(RouterContext)
99
const pageUrl = window.location.href
1010
const fnName = location.params?.page || ''
@@ -18,9 +18,9 @@ export default function Issue() {
1818
<ul>
1919
<li>
2020
<div>
21-
<Link
21+
<RouterLink
22+
class={styles.link}
2223
decorated
23-
tag={RouterLink}
2424
to={{
2525
name: 'docs',
2626
params: {
@@ -29,7 +29,7 @@ export default function Issue() {
2929
}}
3030
>
3131
Suggest edits by sending a PR
32-
</Link>
32+
</RouterLink>
3333
</div>
3434
</li>
3535

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { style } from '@vanilla-extract/css'
2+
3+
export const link = style({
4+
color: '#862d5b',
5+
textDecoration: 'none',
6+
})
File renamed without changes.

src/ui/components/Home/HomeAction.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { h, FunctionComponent } from 'preact'
22
import { RouterLink, AppRouteRef } from '~/ui/router'
3-
import { Action } from './style.css'
3+
import * as styles from './styles.css'
44

55
interface Props {
66
to: AppRouteRef
@@ -12,7 +12,7 @@ export const HomeAction: FunctionComponent<Props> = ({
1212
title,
1313
children,
1414
}) => (
15-
<Action tag={RouterLink} to={to} title={title}>
15+
<RouterLink class={styles.action} to={to} title={title}>
1616
{children}
17-
</Action>
17+
</RouterLink>
1818
)
Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
import { h, ComponentChild, FunctionComponent } from 'preact'
2-
import {
3-
Block,
4-
InnerContainer,
5-
Header,
6-
SubHeader,
7-
Content,
8-
Actions,
9-
} from './style.css'
2+
import * as styles from './styles.css'
103

114
interface Props {
125
header?: ComponentChild
@@ -20,15 +13,15 @@ export const HomeBlock: FunctionComponent<Props> = ({
2013
actions,
2114
children,
2215
}) => (
23-
<Block>
24-
<InnerContainer>
25-
{header && <Header>{header}</Header>}
16+
<div class={styles.block}>
17+
<div class={styles.innerContainer}>
18+
{header && <h2 class={styles.header}>{header}</h2>}
2619

27-
{subHeader && <SubHeader>{subHeader}</SubHeader>}
20+
{subHeader && <h3 class={styles.subHeader}>{subHeader}</h3>}
2821

29-
<Content>{children}</Content>
22+
<div class={styles.content}>{children}</div>
3023

31-
<Actions>{actions}</Actions>
32-
</InnerContainer>
33-
</Block>
24+
<div class={styles.actions}>{actions}</div>
25+
</div>
26+
</div>
3427
)
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { h, FunctionComponent } from 'preact'
2-
import { Button } from './style.css'
2+
import classNames from 'classnames'
3+
import * as styles from './styles.css'
34

45
interface Props {
56
href: string
67
newTab?: boolean
7-
type: 'primary' | 'secondary'
8+
type: keyof typeof styles.button
89
}
910

1011
export const HomeButton: FunctionComponent<Props> = ({
@@ -13,13 +14,13 @@ export const HomeButton: FunctionComponent<Props> = ({
1314
newTab,
1415
type,
1516
}) => (
16-
<Button
17-
tag="a"
17+
<a
18+
class={classNames(styles.button[type])}
1819
href={href}
1920
target={newTab ? '_blank' : undefined}
2021
rel={newTab ? 'noopener noreferrer' : undefined}
2122
type={type}
2223
>
2324
{children}
24-
</Button>
25+
</a>
2526
)

src/ui/components/Home/HomeExternalAction.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { h, FunctionComponent } from 'preact'
2-
import { Action } from './style.css'
2+
import * as styles from './styles.css'
33

44
interface Props {
55
href: string
@@ -11,7 +11,7 @@ export const HomeExternalAction: FunctionComponent<Props> = ({
1111
title,
1212
children,
1313
}) => (
14-
<Action tag="a" href={href} title={title}>
14+
<a class={styles.action} href={href} title={title}>
1515
{children}
16-
</Action>
16+
</a>
1717
)

0 commit comments

Comments
 (0)