-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
163 additions
and
65 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
11 changes: 7 additions & 4 deletions
11
src/web/focus/focus.module.css → src/web/outline/outline.module.css
This file contains 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,12 +1,15 @@ | ||
.focus { | ||
.onActive, | ||
.onFocus { | ||
transition: outline 300ms var(--ease); | ||
} | ||
|
||
.focus, | ||
.focus:focus { | ||
.onActive, | ||
.onFocus, | ||
.onFocus:focus { | ||
outline: solid 8px transparent; | ||
} | ||
|
||
.focus:focus-visible { | ||
.onActive.active, | ||
.onFocus:focus-visible { | ||
outline: solid 2px var(--color-rose); | ||
} |
This file contains 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,7 @@ | ||
import * as s from "./outline.module.css"; | ||
|
||
export const outline = { | ||
onFocus: s.onFocus, | ||
onActive: s.onActive, | ||
active: s.active, | ||
}; |
This file contains 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 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 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 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 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,5 @@ | ||
.container { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
} |
This file contains 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,22 @@ | ||
import { Switch } from "@headlessui/react"; | ||
import { SwitchButton } from "../../switch/switch"; | ||
import s from "./switch.module.css"; | ||
|
||
interface Props { | ||
checked: boolean; | ||
setChecked: (checked: boolean) => void; | ||
label: string; | ||
} | ||
|
||
export const SettingsSwitch = (props: Props): JSX.Element => { | ||
const { checked, setChecked, label } = props; | ||
return ( | ||
<Switch.Group> | ||
{/* Switch.Group is not a real element and cannot have className */} | ||
<div className={s.container}> | ||
<Switch.Label>{label}</Switch.Label> | ||
<SwitchButton checked={checked} setChecked={setChecked} /> | ||
</div> | ||
</Switch.Group> | ||
); | ||
}; |
This file contains 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,21 +1,17 @@ | ||
import { SettingsSwitch } from "./switch/switch"; | ||
import { SettingsState } from "./type"; | ||
import { Switch } from "@headlessui/react"; | ||
|
||
interface Props extends SettingsState {} | ||
|
||
export const SettingsVim = (props: Props): JSX.Element => { | ||
const { setSettings, settings } = props; | ||
return ( | ||
<Switch.Group> | ||
<Switch.Label>Vim mode</Switch.Label> | ||
<Switch | ||
checked={settings.vim} | ||
onChange={(checked) => { | ||
setSettings((prev) => ({ ...prev, vim: checked })); | ||
}} | ||
> | ||
<span>{settings.vim ? "yes" : "no"}</span> | ||
</Switch> | ||
</Switch.Group> | ||
<SettingsSwitch | ||
label="Vim mode" | ||
checked={settings.vim} | ||
setChecked={(checked) => { | ||
setSettings((prev) => ({ ...prev, vim: checked })); | ||
}} | ||
/> | ||
); | ||
}; |
This file contains 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,40 @@ | ||
.container { | ||
display: flex; | ||
position: relative; | ||
|
||
appearance: none; | ||
background-color: var(--color-overlay); | ||
border: none; | ||
border-radius: 999px; | ||
padding: 3px; | ||
} | ||
|
||
.container:active { | ||
background-color: var(--color-highlightMed); | ||
} | ||
|
||
.icon { | ||
flex: 0 0 auto; | ||
} | ||
|
||
.icon svg { | ||
display: block !important; | ||
transform: scale(0.75); | ||
} | ||
|
||
.thumb { | ||
width: 18px; | ||
height: 18px; | ||
border-radius: 20px; | ||
background-color: var(--color-subtle); | ||
|
||
position: absolute; | ||
top: 2px; | ||
left: 2px; | ||
|
||
transition: transform 200ms var(--ease); | ||
} | ||
|
||
.active .thumb { | ||
transform: translateX(16px); | ||
} |
This file contains 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,31 @@ | ||
import { Switch } from "@headlessui/react"; | ||
import { XIcon, CheckIcon } from "@primer/octicons-react"; | ||
import { outline } from "../outline/outline"; | ||
import * as s from "./switch.module.css"; | ||
|
||
interface Props { | ||
checked: boolean; | ||
setChecked: (checked: boolean) => void; | ||
} | ||
|
||
export const SwitchButton = (props: Props): JSX.Element => { | ||
const { checked, setChecked } = props; | ||
|
||
return ( | ||
<Switch | ||
checked={checked} | ||
onChange={setChecked} | ||
className={[s.container, checked ? s.active : "", outline.onFocus].join( | ||
" " | ||
)} | ||
> | ||
<span aria-hidden className={s.icon}> | ||
<CheckIcon size={16} /> | ||
</span> | ||
<span aria-hidden className={s.icon}> | ||
<XIcon size={16} /> | ||
</span> | ||
<span aria-hidden className={s.thumb} /> | ||
</Switch> | ||
); | ||
}; |
This file contains 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 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,28 +1,25 @@ | ||
import { Icon } from "@primer/octicons-react"; | ||
import { ButtonHTMLAttributes, ElementType, forwardRef } from "react"; | ||
import { focusStyle } from "../../focus/focus"; | ||
import { ButtonHTMLAttributes } from "react"; | ||
import { outline } from "../../outline/outline"; | ||
import * as s from "./button.module.css"; | ||
|
||
interface Props extends ButtonHTMLAttributes<HTMLButtonElement> { | ||
Icon: Icon; | ||
label: string; | ||
selected?: boolean; | ||
as?: ElementType; | ||
} | ||
|
||
export const ToolbarButton = forwardRef<HTMLElement, Props>( | ||
(props, ref): JSX.Element => { | ||
const { Icon, label, selected, as, ...rest } = props; | ||
const Button = as ?? "button"; | ||
return ( | ||
<Button | ||
{...rest} | ||
type="button" | ||
className={[s.button, selected ? s.selected : "", focusStyle].join(" ")} | ||
ref={ref} | ||
> | ||
<Icon size={16} aria-label={label} /> | ||
</Button> | ||
); | ||
} | ||
); | ||
export const ToolbarButton = (props: Props): JSX.Element => { | ||
const { Icon, label, selected, ...rest } = props; | ||
return ( | ||
<button | ||
{...rest} | ||
type="button" | ||
className={[s.button, selected ? s.selected : "", outline.onFocus].join( | ||
" " | ||
)} | ||
> | ||
<Icon size={16} aria-label={label} /> | ||
</button> | ||
); | ||
}; |
This file contains 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 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