Skip to content

Commit

Permalink
fix: Improve Setting panel styling
Browse files Browse the repository at this point in the history
  • Loading branch information
thien-do committed Aug 10, 2022
1 parent b4b7845 commit 1df5b25
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 115 deletions.
113 changes: 47 additions & 66 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
"typescript-plugin-css-modules": "^3.4.0"
},
"dependencies": {
"@floating-ui/react-dom": "^1.0.0",
"@headlessui/react": "^1.6.6",
"@primer/octicons-react": "^17.4.0",
"@rose-pine/palette": "^3.0.1",
"monaco-editor": "^0.31.0",
"monaco-vim": "^0.3.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-popper": "^2.3.0",
"rehype-dom-stringify": "^3.0.1",
"rehype-source-map": "^1.0.1",
"remark-gfm": "^3.0.1",
Expand Down
28 changes: 10 additions & 18 deletions src/web/settings/panel.module.css
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
.wrapper {
/* Reliable offset to anchor and screen */
padding: 8px;
padding: 6px;
}

.container {
width: 320px;
max-height: 80vh;
max-height: 70vh;
overflow: auto;

padding: 18px;
/* inner radius + padding / 2 */
border-radius: calc(6px + 18px / 2);

background-color: rgba(var(--color-surface-rgb), 0.7);
backdrop-filter: blur(20px);
border-radius: calc(12px + 16px / 2);
border: solid 1px var(--color-highlightHigh);

display: flex;
flex-direction: column;
gap: 12px;
padding: 16px;
gap: 18px;

box-shadow: 0 1px 2px rgba(0, 0, 0, var(--shadow-opacity)),
0 2px 4px rgba(0, 0, 0, var(--shadow-opacity)),
Expand All @@ -26,17 +28,7 @@
0 32px 64px rgba(0, 0, 0, var(--shadow-opacity));
}

.group {
padding: 6px;
/* background-color: var(--color-surface); */
border-radius: calc(9px + 6px / 2);

display: flex;
flex-direction: column;
gap: 12px;
}

.line {
border: none;
border-bottom: solid 1px var(--color-highlightMed);
.item + .item {
border-top: solid 1px var(--color-highlightMed);
padding-top: 18px;
}
24 changes: 11 additions & 13 deletions src/web/settings/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,17 @@ export const SettingsPanel = (props: Props): JSX.Element => {
return (
<div className={s.wrapper}>
<div className={s.container}>
<div className={s.group}>
<SettingsTheme {...props} />
</div>
<div className={s.group}>
<SettingsPreview {...props} />
</div>
<div className={s.group}>
<SettingsVim {...props} />
<hr className={s.line} />
<SettingsWrapColumn {...props} />
<hr className={s.line} />
<SettingsFontSize {...props} />
</div>
{[
<SettingsTheme {...props} />,
<SettingsPreview {...props} />,
<SettingsVim {...props} />,
<SettingsWrapColumn {...props} />,
<SettingsFontSize {...props} />,
].map((element, index) => (
<div className={s.item} key={index}>
{element}
</div>
))}
</div>
</div>
);
Expand Down
3 changes: 1 addition & 2 deletions src/web/settings/preview/icon.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.container {
padding: 12px 0;
background-color: var(--color-surface);
border-radius: 6px;
background-color: var(--color-base);
display: flex;
width: 72px;
justify-content: center;
Expand Down
1 change: 0 additions & 1 deletion src/web/settings/radio/group.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
}

.label {
padding: 6px;
}
8 changes: 4 additions & 4 deletions src/web/settings/radio/option.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;

gap: 6px;
padding: 6px;
border-radius: calc(6px + 6px / 2);
border-radius: 6px;
}

.label {
Expand All @@ -20,8 +19,9 @@
}

.icon {
border-radius: 6px;
overflow: hidden;
/* outer radius - padding / 2 */
border-radius: calc(6px - 6px / 2);
}

.selected {
Expand Down
2 changes: 1 addition & 1 deletion src/web/toolbar/button/button.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.button {
background: none;
border: none;
padding: 8px;
padding: 8px 9px;
border-radius: 6px;
color: var(--color-subtle);
}
Expand Down
18 changes: 9 additions & 9 deletions src/web/toolbar/settings/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { shift, useFloating } from "@floating-ui/react-dom";
import { Popover } from "@headlessui/react";
import { GearIcon } from "@primer/octicons-react";
import { useState } from "react";
import { usePopper } from "react-popper";
import { LayoutState } from "../../layout/type";
import { SettingsPanel } from "../../settings/panel";
import { SettingsState } from "../../settings/type";
Expand All @@ -10,25 +9,26 @@ import { ToolbarButton } from "./../button/button";
interface Props extends SettingsState, LayoutState {}

export const ToolbarSettings = (props: Props): JSX.Element => {
const [button, setButton] = useState<HTMLElement | null>(null);
const [popover, setPopover] = useState<HTMLElement | null>(null);
const { styles, attributes } = usePopper(button, popover);
const float = useFloating({ middleware: [shift()] });

return (
<Popover>
{({ open }) => (
<>
<ToolbarButton
ref={setButton}
ref={float.reference}
as={Popover.Button}
Icon={GearIcon}
label="Settings"
selected={open}
/>
<Popover.Panel
ref={setPopover}
style={styles.popper}
{...attributes.popper}
ref={float.floating}
style={{
position: float.strategy,
top: float.y ?? 0,
left: float.x ?? 0,
}}
>
<SettingsPanel {...props} />
</Popover.Panel>
Expand Down

0 comments on commit 1df5b25

Please sign in to comment.