Skip to content

Commit 2193916

Browse files
committed
Get basic compiling working with new CSS setup
1 parent 7b75e7a commit 2193916

18 files changed

+2161
-961
lines changed

.babel-plugin-macrosrc.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
twin: {
3+
preset: 'styled-components',
4+
autoCssProp: true,
5+
config: './tailwind.config.js',
6+
},
7+
styledComponents: {
8+
pure: true,
9+
displayName: false,
10+
fileName: false,
11+
},
12+
};

babel.config.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
presets: [
3+
'@babel/typescript',
4+
['@babel/env', {
5+
modules: false,
6+
useBuiltIns: 'entry',
7+
corejs: 3,
8+
}],
9+
'@babel/react',
10+
],
11+
plugins: [
12+
'babel-plugin-macros',
13+
'styled-components',
14+
'react-hot-loader/babel',
15+
'@babel/transform-runtime',
16+
'@babel/transform-react-jsx',
17+
'@babel/proposal-class-properties',
18+
'@babel/proposal-object-rest-spread',
19+
'@babel/proposal-optional-chaining',
20+
'@babel/proposal-nullish-coalescing-operator',
21+
'@babel/syntax-dynamic-import',
22+
],
23+
};

package.json

+34-30
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"@fortawesome/free-solid-svg-icons": "^5.9.0",
66
"@fortawesome/react-fontawesome": "^0.1.4",
77
"@types/react-google-recaptcha": "^1.1.1",
8-
"axios": "^0.19.0",
8+
"axios": "^0.19.2",
99
"ayu-ace": "^2.0.4",
1010
"brace": "^0.11.1",
1111
"chart.js": "^2.8.0",
1212
"classnames": "^2.2.6",
13-
"date-fns": "^1.29.0",
14-
"easy-peasy": "^3.2.3",
13+
"date-fns": "^2.14.0",
14+
"easy-peasy": "^3.3.1",
1515
"events": "^3.0.0",
1616
"formik": "^2.1.4",
1717
"i18next": "^19.0.0",
@@ -22,23 +22,23 @@
2222
"lodash-es": "^4.17.15",
2323
"path": "^0.12.7",
2424
"query-string": "^6.7.0",
25-
"react": "^16.12.0",
25+
"react": "^16.13.1",
2626
"react-dom": "npm:@hot-loader/react-dom",
2727
"react-google-recaptcha": "^2.0.1",
28-
"react-hot-loader": "^4.12.18",
28+
"react-hot-loader": "^4.12.21",
2929
"react-i18next": "^11.2.1",
3030
"react-redux": "^7.1.0",
3131
"react-router-dom": "^5.1.2",
3232
"react-transition-group": "^4.3.0",
3333
"sockette": "^2.0.6",
34-
"styled-components": "^4.4.1",
34+
"styled-components": "^5.1.1",
3535
"styled-components-breakpoint": "^3.0.0-preview.20",
3636
"use-react-router": "^1.0.7",
3737
"uuid": "^3.3.2",
3838
"xterm": "^3.14.4",
3939
"xterm-addon-attach": "^0.1.0",
4040
"xterm-addon-fit": "^0.1.0",
41-
"yup": "^0.27.0"
41+
"yup": "^0.29.1"
4242
},
4343
"devDependencies": {
4444
"@babel/core": "^7.7.5",
@@ -47,6 +47,7 @@
4747
"@babel/plugin-proposal-object-rest-spread": "^7.7.4",
4848
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
4949
"@babel/plugin-syntax-dynamic-import": "^7.7.4",
50+
"@babel/plugin-transform-react-jsx": "^7.10.4",
5051
"@babel/plugin-transform-runtime": "^7.7.5",
5152
"@babel/preset-env": "^7.7.5",
5253
"@babel/preset-react": "^7.7.4",
@@ -60,32 +61,33 @@
6061
"@types/lodash-es": "^4.17.3",
6162
"@types/node": "^12.6.9",
6263
"@types/query-string": "^6.3.0",
63-
"@types/react": "^16.9.15",
64-
"@types/react-dom": "^16.9.4",
64+
"@types/react": "^16.9.41",
65+
"@types/react-dom": "^16.9.8",
6566
"@types/react-redux": "^7.1.1",
6667
"@types/react-router": "^5.1.3",
6768
"@types/react-router-dom": "^5.1.3",
6869
"@types/react-transition-group": "^2.9.2",
6970
"@types/styled-components": "^4.4.0",
7071
"@types/uuid": "^3.4.5",
71-
"@types/webpack-env": "^1.13.6",
72-
"@types/yup": "^0.26.17",
73-
"@typescript-eslint/eslint-plugin": "^2.19.0",
74-
"@typescript-eslint/parser": "^2.19.0",
72+
"@types/webpack-env": "^1.15.2",
73+
"@types/yup": "^0.29.3",
74+
"@typescript-eslint/eslint-plugin": "^3.5.0",
75+
"@typescript-eslint/parser": "^3.5.0",
7576
"babel-loader": "^8.0.6",
76-
"babel-plugin-styled-components": "^1.10.6",
77+
"babel-plugin-styled-components": "^1.10.7",
7778
"babel-plugin-tailwind-components": "^0.5.10",
7879
"cross-env": "^7.0.2",
7980
"css-loader": "^3.2.1",
8081
"cssnano": "^4.1.10",
81-
"eslint": "^5.16.0",
82-
"eslint-config-standard": "^12.0.0",
83-
"eslint-plugin-import": "^2.17.3",
82+
"eslint": "^7.4.0",
83+
"eslint-config-standard": "^14.1.1",
84+
"eslint-plugin-import": "^2.22.0",
8485
"eslint-plugin-node": "^9.1.0",
85-
"eslint-plugin-promise": "^4.1.1",
86-
"eslint-plugin-react-hooks": "^2.1.2",
87-
"eslint-plugin-standard": "^4.0.0",
88-
"fork-ts-checker-webpack-plugin": "^1.5.0",
86+
"eslint-plugin-promise": "^4.2.1",
87+
"eslint-plugin-react": "^7.20.3",
88+
"eslint-plugin-react-hooks": "^4.0.5",
89+
"eslint-plugin-standard": "^4.0.1",
90+
"fork-ts-checker-webpack-plugin": "^5.0.6",
8991
"glob-all": "^3.1.0",
9092
"html-webpack-plugin": "^3.2.0",
9193
"mini-css-extract-plugin": "^0.8.0",
@@ -97,17 +99,19 @@
9799
"purgecss-webpack-plugin": "^1.6.0",
98100
"redux-devtools-extension": "^2.13.8",
99101
"resolve-url-loader": "^3.0.0",
100-
"source-map-loader": "^0.2.4",
101-
"style-loader": "^0.23.1",
102-
"tailwindcss": "^0.7.4",
103-
"terser-webpack-plugin": "^1.3.0",
102+
"source-map-loader": "^1.0.1",
103+
"style-loader": "^1.2.1",
104+
"tailwindcss": "^1.4.6",
105+
"terser-webpack-plugin": "^3.0.6",
104106
"ts-loader": "^6.2.1",
105-
"typescript": "^3.7.5",
106-
"webpack": "^4.41.2",
107+
"twin.macro": "^1.4.1",
108+
"typescript": "^3.9.6",
109+
"typescript-plugin-tw-template": "^2.0.1",
110+
"webpack": "^4.43.0",
107111
"webpack-assets-manifest": "^3.1.1",
108-
"webpack-cli": "^3.3.10",
109-
"webpack-dev-server": "^3.9.0",
110-
"webpack-manifest-plugin": "^2.0.3",
112+
"webpack-cli": "^3.3.12",
113+
"webpack-dev-server": "^3.11.0",
114+
"webpack-manifest-plugin": "^2.2.0",
111115
"yarn-deduplicate": "^1.1.1"
112116
},
113117
"scripts": {

resources/scripts/.eslintrc.yml

+34-3
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
11
parser: "@typescript-eslint/parser"
22
parserOptions:
33
ecmaVersion: 6
4+
ecmaFeatures:
5+
jsx: true
46
project: "./tsconfig.json"
57
tsconfigRootDir: "./"
8+
settings:
9+
react:
10+
pragma: "React"
11+
version: "detect"
12+
linkComponents:
13+
- name: Link
14+
linkAttribute: to
15+
- name: NavLink
16+
linkAttribute: to
617
env:
718
browser: true
819
es6: true
920
plugins:
10-
- "@typescript-eslint"
21+
- "react"
1122
- "react-hooks"
23+
- "@typescript-eslint"
1224
extends:
1325
- "standard"
26+
- "plugin:react/recommended"
1427
- "plugin:@typescript-eslint/recommended"
15-
globals:
16-
tw: "readonly"
1728
rules:
1829
indent:
1930
- error
2031
- 4
32+
- SwitchCase: 1
2133
semi:
2234
- error
2335
- always
@@ -33,6 +45,25 @@ rules:
3345
"@typescript-eslint/no-unused-vars": 0
3446
"@typescript-eslint/no-explicit-any": 0
3547
"@typescript-eslint/no-non-null-assertion": 0
48+
no-restricted-imports:
49+
- error
50+
- paths:
51+
- name: styled-components
52+
message: Please import from styled-components/macro.
53+
patterns:
54+
- "!styled-components/macro"
55+
"react/prop-types": 0
56+
"react/display-name": 0
57+
"react/jsx-indent-props":
58+
- warn
59+
- 4
60+
"react/jsx-boolean-value":
61+
- warn
62+
- never
63+
"react/jsx-closing-bracket-location":
64+
- 1
65+
- "line-aligned"
66+
"react/jsx-closing-tag-location": 1
3667
overrides:
3768
- files:
3869
- "**/*.tsx"

resources/scripts/components/App.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ interface ExtendedWindow extends Window {
1818
uuid: string;
1919
username: string;
2020
email: string;
21+
/* eslint-disable camelcase */
2122
root_admin: boolean;
2223
use_totp: boolean;
2324
language: string;
2425
updated_at: string;
2526
created_at: string;
27+
/* eslint-enable camelcase */
2628
};
2729
}
2830

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import styled from 'styled-components';
2-
import { breakpoint } from 'styled-components-breakpoint';
1+
import styled from 'styled-components/macro';
2+
import { breakpoint } from '@/theme';
3+
import tw from 'twin.macro';
34

45
const ContentContainer = styled.div`
56
max-width: 1200px;
@@ -9,5 +10,6 @@ const ContentContainer = styled.div`
910
${tw`mx-auto`};
1011
`};
1112
`;
13+
ContentContainer.displayName = 'ContentContainer';
1214

1315
export default ContentContainer;

resources/scripts/components/server/backups/BackupRow.tsx

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
import React, { useState } from 'react';
1+
import React from 'react';
22
import { ServerBackup } from '@/api/server/backups/getServerBackups';
33
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
44
import { faArchive } from '@fortawesome/free-solid-svg-icons/faArchive';
5-
import format from 'date-fns/format';
6-
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now';
5+
import { format, formatDistanceToNow } from 'date-fns';
76
import Spinner from '@/components/elements/Spinner';
8-
import Modal, { RequiredModalProps } from '@/components/elements/Modal';
97
import { bytesToHuman } from '@/helpers';
108
import Can from '@/components/elements/Can';
11-
import useServer from '@/plugins/useServer';
12-
import getBackupDownloadUrl from '@/api/server/backups/getBackupDownloadUrl';
13-
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
14-
import useFlash from '@/plugins/useFlash';
15-
import { httpErrorToHuman } from '@/api/http';
169
import useWebsocketEvent from '@/plugins/useWebsocketEvent';
1710
import { ServerContext } from '@/state/server';
1811
import BackupContextMenu from '@/components/server/backups/BackupContextMenu';
@@ -65,7 +58,7 @@ export default ({ backup, className }: Props) => {
6558
title={format(backup.createdAt, 'ddd, MMMM Do, YYYY HH:mm:ss Z')}
6659
className={'text-sm'}
6760
>
68-
{distanceInWordsToNow(backup.createdAt, { includeSeconds: true, addSuffix: true })}
61+
{formatDistanceToNow(backup.createdAt, { includeSeconds: true, addSuffix: true })}
6962
</p>
7063
<p className={'text-2xs text-neutral-500 uppercase mt-1'}>Created</p>
7164
</div>

resources/scripts/components/server/files/FileObjectRow.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { faFileImport } from '@fortawesome/free-solid-svg-icons/faFileImport';
33
import { faFileAlt } from '@fortawesome/free-solid-svg-icons/faFileAlt';
44
import { faFolder } from '@fortawesome/free-solid-svg-icons/faFolder';
55
import { bytesToHuman, cleanDirectoryPath } from '@/helpers';
6-
import differenceInHours from 'date-fns/difference_in_hours';
7-
import format from 'date-fns/format';
8-
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now';
6+
import { differenceInHours, format, formatDistanceToNow } from 'date-fns';
97
import React from 'react';
108
import { FileObject } from '@/api/server/files/loadDirectory';
119
import FileDropdownMenu from '@/components/server/files/FileDropdownMenu';
@@ -65,7 +63,7 @@ export default ({ file }: { file: FileObject }) => {
6563
{Math.abs(differenceInHours(file.modifiedAt, new Date())) > 48 ?
6664
format(file.modifiedAt, 'MMM Do, YYYY h:mma')
6765
:
68-
distanceInWordsToNow(file.modifiedAt, { addSuffix: true })
66+
formatDistanceToNow(file.modifiedAt, { addSuffix: true })
6967
}
7068
</div>
7169
</NavLink>

resources/scripts/gloabl.d.ts

-1
This file was deleted.

resources/scripts/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import App from '@/components/App';
44
import './i18n';
55
import { setConfig } from 'react-hot-loader';
66

7+
import 'tailwindcss/dist/base.min.css';
8+
79
// Prevents page reloads while making component changes which
810
// also avoids triggering constant loading indicators all over
911
// the place in development.

resources/scripts/macros.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// This allows the use of css={} on JSX elements.
2+
//
3+
// @see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31245
4+
import {} from 'styled-components/cssprop';

resources/scripts/style.d.ts

-17
This file was deleted.

resources/scripts/theme.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { BreakpointFunction, createBreakpoint } from 'styled-components-breakpoint';
2+
3+
type Breakpoints = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
4+
export const breakpoint: BreakpointFunction<Breakpoints> = createBreakpoint<Breakpoints>({
5+
xs: 0,
6+
sm: 640,
7+
md: 768,
8+
lg: 1024,
9+
xl: 1280,
10+
});

resources/views/templates/wrapper.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
@show
3333

3434
@section('assets')
35-
{!! $asset->css('main.css') !!}
35+
{{-- {!! $asset->css('main.css') !!}--}}
3636
@show
3737

3838
@include('layouts.scripts')

0 commit comments

Comments
 (0)