-
Notifications
You must be signed in to change notification settings - Fork 2
Use CSS modules #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Use CSS modules #188
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
557783a
move Welcome CSS to a CSS module + allow overriding
severo 0d39fab
remove redundant declaration
severo 90ffb0a
fix type
severo dbf56e2
extract SideBar to its component + CSS module
severo 4eb2408
reverse the config keys to group all class names under customClass
severo 7102033
style
severo ba03e51
move TextView styles to CSS module
severo 3fe4514
move MarkdownView styles to CSS module
severo 126198a
fix import paths
severo 7e91ca2
move ImageView styles to CSS module
severo 661247e
move ContentHeader styles to CSS module
severo 45e4969
rename ContentHeader as ContentWrapper
severo b73d419
move Spinner styles to CSS module + move to a new component file
severo 283bace
move ErrorBar styles to CSS module + new component
severo 39cbe2d
split Layout.test.tsx in three files
severo 0fde1db
fix the tests + use VisuallyHidden component to insert accessible text
severo 76a1f29
extract SlideCloseButton to its own component + CSS module
severo 131ca4f
fix ErrorBar: don't take space when hidden
severo 7ec75af
fix class name
severo ed07ac9
Move styles for SlidePanel to a CSS module
severo e39d855
Fix SlidePanel tests, and change panel from article to aside
severo e7b71dd
Move the progress bar to its component + CSS module
severo 55af56b
fix bug in the computation of path parts
severo 65c1a83
fix again the source parts
severo 2eb13be
Move breadcrumb styles to CSS module + move tests their own file
severo c501fa4
extract Layout styles to CSS Module
severo c68c4c5
extract Center as a new component, and move the loading spinner to Co…
severo a005bed
memoize the list of files
severo fa5882d
refactor the conditionals for safety
severo 2c9d13d
fix the conditionals: we work on filtered, not files
severo 49fed0d
use CSS module for Folder styles
severo e94cdfc
move search styles to Folder CSS module
severo 4c98b3b
remove useless intermediate top-actions div
severo fc3c27a
export global CSS in the package
severo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { ReactNode } from 'react' | ||
| import { useConfig } from '../hooks/useConfig.js' | ||
| import { cn } from '../lib/utils.js' | ||
| import styles from '../styles/Center.module.css' | ||
|
|
||
| export default function Center({ children }: {children?: ReactNode}) { | ||
| const { customClass } = useConfig() | ||
| return <div className={cn(styles.center, customClass?.center)}>{children}</div> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { useState } from 'react' | ||
| import { useConfig } from '../hooks/useConfig.js' | ||
| import { cn } from '../lib/utils.js' | ||
| import styles from '../styles/ErrorBar.module.css' | ||
|
|
||
| interface ErrorBarProps { | ||
| error?: Error | ||
| } | ||
|
|
||
| export default function ErrorBar({ error }: ErrorBarProps) { | ||
| const [showError, setShowError] = useState(error !== undefined) | ||
| const [prevError, setPrevError] = useState(error) | ||
| const { customClass } = useConfig() | ||
|
|
||
| if (error) console.error(error) | ||
| /// Reset error visibility when error prop changes | ||
| if (error !== prevError) { | ||
| setPrevError(error) | ||
| setShowError(error !== undefined) | ||
| } | ||
|
|
||
| return <div | ||
| className={cn(styles.errorBar, customClass?.errorBar)} | ||
| data-visible={showError} | ||
| > | ||
| <div> | ||
| <span>{error?.toString()}</span> | ||
| <button | ||
| aria-label='Close error message' | ||
| onClick={() => { setShowError(false) }}> | ||
| × | ||
| </button> | ||
| </div> | ||
| </div> | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { useConfig } from '../hooks/useConfig' | ||
| import { cn } from '../lib/utils.js' | ||
| import styles from '../styles/ProgressBar.module.css' | ||
| import VisuallyHidden from './VisuallyHidden.js' | ||
|
|
||
| export default function ProgressBar({ value }: {value: number}) { | ||
| const { customClass } = useConfig() | ||
| if (value < 0 || value > 1) { | ||
| throw new Error('ProgressBar value must be between 0 and 1') | ||
| } | ||
| const roundedValue = Math.round(value * 100) / 100 | ||
| const percentage = roundedValue.toLocaleString('en-US', { style: 'percent' }) | ||
| return ( | ||
| <div | ||
| className={cn(styles.progressBar, customClass?.progressBar)} | ||
| role='progressbar' | ||
| aria-valuenow={roundedValue} | ||
| aria-valuemin={0} | ||
| aria-valuemax={1} | ||
| > | ||
| <VisuallyHidden>{percentage}</VisuallyHidden> | ||
| <div style={{ width: percentage }} role="presentation" /> | ||
| </div> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { useConfig } from '../hooks/useConfig.js' | ||
| import { cn } from '../lib/utils.js' | ||
| import styles from '../styles/SideBar.module.css' | ||
|
|
||
| export default function SideBar() { | ||
| const { customClass } = useConfig() | ||
| return <nav className={cn(styles.sideBar, customClass?.sideBar)}> | ||
| <div> | ||
| <a className={cn(styles.brand, customClass?.brand)} href='/'>hyperparam</a> | ||
| </div> | ||
| </nav> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { MouseEventHandler } from 'react' | ||
| import { useConfig } from '../hooks/useConfig.js' | ||
| import { cn } from '../lib/utils.js' | ||
| import styles from '../styles/SlideCloseButton.module.css' | ||
|
|
||
| export default function SlideCloseButton({ onClick }: { onClick: MouseEventHandler<HTMLButtonElement> | undefined }) { | ||
| const { customClass } = useConfig() | ||
| return ( | ||
| <button className={ cn( styles.slideClose, customClass?.slideCloseButton ) } onClick={onClick}> </button> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { useConfig } from '../hooks/useConfig.js' | ||
| import { cn } from '../lib/utils.js' | ||
| import styles from '../styles/Spinner.module.css' | ||
| import VisuallyHidden from './VisuallyHidden.js' | ||
|
|
||
| export default function Spinner({ text }: {text?: string}) { | ||
| const { customClass } = useConfig() | ||
| const spinnerText = text ?? 'Loading...' | ||
| return <div | ||
| className={cn(styles.spinner, customClass?.spinner)} | ||
| role='status' | ||
| aria-live='polite' | ||
| ><VisuallyHidden>{spinnerText}</VisuallyHidden></div> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { HTMLAttributes } from 'react' | ||
| import styles from '../styles/VisuallyHidden.module.css' | ||
|
|
||
| export default function VisuallyHidden({ children, ...delegated }: HTMLAttributes<HTMLElement>) { | ||
| return <div className={styles.wrapper} {...delegated}>{children}</div> | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| import Breadcrumb from './Breadcrumb.js' | ||
| import Cell from './Cell.js' | ||
| import ErrorBar from './ErrorBar.js' | ||
| import File from './File.js' | ||
| import Folder from './Folder.js' | ||
| import Layout, { ErrorBar, Spinner } from './Layout.js' | ||
| import Layout from './Layout.js' | ||
| import Markdown from './Markdown.js' | ||
| import Page from './Page.js' | ||
| import Spinner from './Spinner.js' | ||
| export * from './viewers/index.js' | ||
| export { Breadcrumb, Cell, ErrorBar, File, Folder, Layout, Markdown, Page, Spinner } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.