Skip to content

Commit 784e8aa

Browse files
authored
Centralize all CSS imports in index.css for explicit ordering (#2035)
* put text-accent back on sidebar link, fix button styling * fix dialog styles, get rid of dialog.css * move all remaining css imports into css. render unto css what is css's * clean up modal stuff. take pointer events and onclicks off modal overlay
1 parent da07ce0 commit 784e8aa

29 files changed

+127
-136
lines changed

.eslintrc.cjs

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/**
2+
* @type {import("eslint").Linter.Config}
3+
*/
4+
module.exports = {
5+
root: true,
6+
parser: '@typescript-eslint/parser',
7+
parserOptions: {
8+
warnOnUnsupportedTypeScriptVersion: false,
9+
},
10+
extends: [
11+
'eslint:recommended',
12+
'plugin:@typescript-eslint/strict',
13+
'plugin:@typescript-eslint/stylistic',
14+
'plugin:jsx-a11y/recommended',
15+
'plugin:react/recommended',
16+
'prettier',
17+
'plugin:react-hook-form/recommended',
18+
],
19+
plugins: ['@typescript-eslint', 'react-hooks', 'prettier', 'jsx-a11y', 'react-hook-form'],
20+
settings: {
21+
react: {
22+
version: 'detect',
23+
},
24+
},
25+
env: {
26+
node: true,
27+
},
28+
rules: {
29+
'@typescript-eslint/array-type': 'off',
30+
'@typescript-eslint/consistent-type-definitions': 'off',
31+
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
32+
'@typescript-eslint/no-empty-function': 'off',
33+
'@typescript-eslint/no-empty-interface': 'off',
34+
'@typescript-eslint/ban-ts-comment': 'off',
35+
'@typescript-eslint/no-non-null-assertion': 'off',
36+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
37+
eqeqeq: ['error', 'always', { null: 'ignore' }],
38+
'jsx-a11y/label-has-associated-control': [2, { controlComponents: ['button'] }],
39+
'no-param-reassign': 'error',
40+
'no-restricted-imports': [
41+
'error',
42+
{
43+
paths: [
44+
'.', // preventing confusion due to auto-imports and barrel files
45+
],
46+
patterns: [
47+
// import all CSS except index.css at top level through CSS @import statements
48+
// to avoid bad ordering situations. See https://github.com/oxidecomputer/console/pull/2035
49+
'*.css',
50+
],
51+
},
52+
],
53+
'no-return-assign': 'error',
54+
'no-unused-vars': 'off',
55+
'prefer-arrow-callback': 'off',
56+
'prettier/prettier': 'error',
57+
radix: 'error',
58+
'react-hooks/exhaustive-deps': 'error',
59+
'react-hooks/rules-of-hooks': 'error',
60+
'react/jsx-boolean-value': 'error',
61+
'react/display-name': 'off',
62+
'react/react-in-jsx-scope': 'off',
63+
'react/prop-types': 'off',
64+
},
65+
ignorePatterns: ['dist/'],
66+
overrides: [
67+
{
68+
files: ['*.js'],
69+
rules: {
70+
'@typescript-eslint/no-var-requires': 'off',
71+
},
72+
},
73+
{
74+
files: ['*.e2e.ts'],
75+
extends: ['plugin:playwright/playwright-test'],
76+
rules: {
77+
'playwright/expect-expect': [
78+
'warn',
79+
{ assertFunctionNames: ['expectVisible', 'expectRowVisible'] },
80+
],
81+
},
82+
},
83+
],
84+
}

.eslintrc.json

Lines changed: 0 additions & 75 deletions
This file was deleted.

app/components/Sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export const NavLinkItem = (props: {
9494
to={props.to}
9595
className={({ isActive }) =>
9696
cn(linkStyles, {
97-
'!bg-accent-secondary hover:!bg-accent-secondary-hover svg:!text-accent-tertiary':
97+
'text-accent !bg-accent-secondary hover:!bg-accent-secondary-hover svg:!text-accent-tertiary':
9898
isActive,
9999
'pointer-events-none text-disabled': props.disabled,
100100
})

app/components/form/Form.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import { flattenChildren, isOneOf, pluckFirstOfType } from '~/util/children'
1515
import { classed } from '~/util/classed'
1616
import { invariant } from '~/util/invariant'
1717

18-
import './form.css'
19-
2018
interface FormActionsProps {
2119
formId?: string
2220
children: React.ReactNode

app/main.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import { ReduceMotion } from './hooks'
1919
// stripped out by rollup in production
2020
import { startMockAPI } from './msw-mock-api'
2121
import { routes } from './routes'
22-
22+
// this is the only allowed css import
23+
// eslint-disable-next-line no-restricted-imports
2324
import '~/ui/styles/index.css'
2425

2526
import { SkipLink } from '~/ui/lib/SkipLink'

app/pages/LoginPage.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@ import { useNavigate, useSearchParams } from 'react-router-dom'
1111
import { useApiMutation, type UsernamePasswordCredentials } from '@oxide/api'
1212

1313
import { TextFieldInner } from '~/components/form/fields/TextField'
14+
import { useForm } from '~/hooks'
1415
import { Button } from '~/ui/lib/Button'
1516
import { Identicon } from '~/ui/lib/Identicon'
16-
17-
import '~/components/login-page.css'
18-
19-
import { useForm } from '~/hooks'
2017
import { pb } from '~/util/path-builder'
2118

2219
import { useSiloSelector, useToast } from '../hooks'

app/pages/LoginPageSaml.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import { useSearchParams } from 'react-router-dom'
1111
import { buttonStyle } from '~/ui/lib/Button'
1212
import { Identicon } from '~/ui/lib/Identicon'
1313

14-
import '~/components/login-page.css'
15-
1614
import { useIdpSelector } from '../hooks'
1715

1816
/** SAML "login page" that just links to the actual IdP */

app/ui/lib/ActionMenu.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { KEYS } from '~/ui/util/keys'
1616
import { groupBy } from '~/util/array'
1717
import { classed } from '~/util/classed'
1818

19+
import { DialogOverlay } from './DialogOverlay'
1920
import { useSteppedScroll } from './use-stepped-scroll'
2021

2122
export interface QuickActionItem {
@@ -90,8 +91,8 @@ export function ActionMenu(props: ActionMenuProps) {
9091
}}
9192
>
9293
<Dialog.Portal>
93-
<Dialog.Overlay className="DialogOverlay" />
94-
<Dialog.Content className="DialogContent fixed inset-0 mt-[20vh] !w-[46rem] bg-transparent p-0">
94+
<DialogOverlay />
95+
<Dialog.Content className="fixed inset-0 z-modal mx-auto mt-[20vh] w-[46rem] bg-transparent p-0">
9596
<div
9697
onKeyDown={(e) => {
9798
const lastIdx = itemsInOrder.length - 1

app/ui/lib/Button.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import { Spinner } from '~/ui/lib/Spinner'
1212
import { Tooltip } from '~/ui/lib/Tooltip'
1313
import { Wrap } from '~/ui/util/wrap'
1414

15-
import './button.css'
16-
1715
export const buttonSizes = ['sm', 'icon', 'base'] as const
1816
export const variants = ['primary', 'secondary', 'ghost', 'danger'] as const
1917

app/ui/styles/components/dialog.css renamed to app/ui/lib/DialogOverlay.tsx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,10 @@
22
* This Source Code Form is subject to the terms of the Mozilla Public
33
* License, v. 2.0. If a copy of the MPL was not distributed with this
44
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
5-
*
5+
*
66
* Copyright Oxide Computer Company
77
*/
88

9-
.DialogOverlay {
10-
/* background: hsla(0, 0%, 0%, 0.33); */
11-
@apply fixed inset-0 z-10 overflow-auto bg-scrim;
12-
}
13-
14-
.DialogContent {
15-
@apply z-20;
16-
17-
width: 50vw;
18-
margin: 10vh auto;
19-
background: white;
20-
padding: 2rem;
21-
outline: none;
22-
}
9+
export const DialogOverlay = () => (
10+
<div aria-hidden className="fixed inset-0 z-10 overflow-auto bg-scrim" />
11+
)

0 commit comments

Comments
 (0)