formatting icons: refactor CSS/remove borders

This commit is contained in:
Max Leiter 2022-12-25 23:00:13 -08:00
parent 69a40df606
commit 02695345cd
7 changed files with 66 additions and 37 deletions

View file

@ -14,7 +14,6 @@
.contentWrapper { .contentWrapper {
z-index: 1000; z-index: 1000;
} }
.content { .content {
@ -42,9 +41,7 @@
justify-content: space-between; justify-content: space-between;
color: var(--dark-gray); color: var(--dark-gray);
text-decoration: none; text-decoration: none;
/* vertical alignment */
padding: var(--gap-quarter) 0; padding: var(--gap-quarter) 0;
} }
.content li .fileIcon { .content li .fileIcon {
@ -53,7 +50,6 @@
} }
.content li .fileTitle { .content li .fileTitle {
/* from Geist */
font-size: calc(0.875 * 16px); font-size: calc(0.875 * 16px);
} }

View file

@ -42,16 +42,23 @@ export default function DocumentTabs({
className={styles.root} className={styles.root}
defaultValue={defaultTab} defaultValue={defaultTab}
> >
<RadixTabs.List className={styles.list}> <RadixTabs.List className={styles.listWrapper}>
<RadixTabs.Trigger value="edit" className={styles.trigger}> <div className={styles.list}>
{isEditing ? "Edit" : "Raw"} <RadixTabs.Trigger value="edit" className={styles.trigger}>
</RadixTabs.Trigger> {isEditing ? "Edit" : "Raw"}
<RadixTabs.Trigger value="preview" className={styles.trigger}> </RadixTabs.Trigger>
{isEditing ? "Preview" : "Rendered"} <RadixTabs.Trigger value="preview" className={styles.trigger}>
</RadixTabs.Trigger> {isEditing ? "Preview" : "Rendered"}
</RadixTabs.Trigger>
</div>
{isEditing && (
<FormattingIcons
className={styles.formattingIcons}
textareaRef={codeEditorRef}
/>
)}
</RadixTabs.List> </RadixTabs.List>
<RadixTabs.Content value="edit"> <RadixTabs.Content value="edit">
{isEditing && <FormattingIcons textareaRef={codeEditorRef} />}
<div <div
style={{ style={{
marginTop: 6, marginTop: 6,

View file

@ -3,11 +3,22 @@
flex-direction: column; flex-direction: column;
} }
.listWrapper {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.list { .list {
flex-shrink: 0; flex-shrink: 0;
display: flex; display: flex;
} }
.list .formattingIcons {
margin-left: auto;
}
.trigger { .trigger {
width: 80px; width: 80px;
height: 30px; height: 30px;
@ -41,3 +52,11 @@
color: var(--darkest-gray); color: var(--darkest-gray);
box-shadow: inset 0 -1px 0 0 currentColor, 0 1px 0 0 currentColor; box-shadow: inset 0 -1px 0 0 currentColor, 0 1px 0 0 currentColor;
} }
@media (max-width: 600px) {
.listWrapper {
flex-direction: column;
justify-content: flex-start;
}
}

View file

@ -4,9 +4,7 @@
} }
.actionWrapper .actions { .actionWrapper .actions {
position: absolute;
right: 0;
top: -40px;
} }
/* small screens, top: 0 */ /* small screens, top: 0 */

View file

@ -12,12 +12,15 @@ import { TextareaMarkdownRef } from "textarea-markdown-editor"
import Tooltip from "@components/tooltip" import Tooltip from "@components/tooltip"
import Button from "@components/button" import Button from "@components/button"
import ButtonGroup from "@components/button-group" import ButtonGroup from "@components/button-group"
import clsx from "clsx"
// TODO: clean up // TODO: clean up
const FormattingIcons = ({ const FormattingIcons = ({
textareaRef textareaRef,
className
}: { }: {
textareaRef?: RefObject<TextareaMarkdownRef> textareaRef?: RefObject<TextareaMarkdownRef>
className?: string
}) => { }) => {
const formattingActions = useMemo(() => { const formattingActions = useMemo(() => {
const handleBoldClick = () => textareaRef?.current?.trigger("bold") const handleBoldClick = () => textareaRef?.current?.trigger("bold")
@ -62,22 +65,28 @@ const FormattingIcons = ({
}, [textareaRef]) }, [textareaRef])
return ( return (
<div className={styles.actionWrapper}> <div className={clsx(styles.actionWrapper, className)}>
<ButtonGroup className={styles.actions}> {formattingActions.map(({ icon, name, action }) => (
{formattingActions.map(({ icon, name, action }) => ( <Tooltip
<Tooltip content={name[0].toUpperCase() + name.slice(1).replace("-", " ")}
content={name[0].toUpperCase() + name.slice(1).replace("-", " ")} key={name}
key={name} >
> <Button
<Button height={32}
aria-label={name} style={{
iconRight={icon} fontSize: 14,
onMouseDown={(e) => e.preventDefault()} borderRight: "none",
onClick={action} borderLeft: "none",
/> borderTop: "none",
</Tooltip> borderBottom: "none"
))} }}
</ButtonGroup> aria-label={name}
iconRight={icon}
onMouseDown={(e) => e.preventDefault()}
onClick={action}
/>
</Tooltip>
))}
</div> </div>
) )
} }

View file

@ -84,7 +84,7 @@ const Document = ({ skeleton, ...props }: Props) => {
// if the query has our title, we can use it to scroll to the file. // if the query has our title, we can use it to scroll to the file.
// we can't use the browsers implementation because the data isn't loaded yet // we can't use the browsers implementation because the data isn't loaded yet
if (title) { if (title && typeof window !== "undefined") {
const hash = window.location.hash const hash = window.location.hash
if (hash && hash === `#${title}`) { if (hash && hash === `#${title}`) {
const element = document.getElementById(title) const element = document.getElementById(title)

View file

@ -14,12 +14,12 @@
border-radius: 0 !important; border-radius: 0 !important;
} }
.button-group > button:first-of-type { .button-group button:first-of-type {
border-top-left-radius: var(--radius) !important; border-top-left-radius: var(--radius) !important;
border-bottom-left-radius: var(--radius) !important; border-bottom-left-radius: var(--radius) !important;
} }
.button-group > button:last-of-type { .button-group button:last-of-type {
border-top-right-radius: var(--radius) !important; border-top-right-radius: var(--radius) !important;
border-bottom-right-radius: var(--radius) !important; border-bottom-right-radius: var(--radius) !important;
} }
@ -29,14 +29,14 @@
flex-direction: column !important; flex-direction: column !important;
} }
.verticalIfMobile.button-group > button:first-of-type { .verticalIfMobile.button-group button:first-of-type {
border-top-left-radius: var(--radius) !important; border-top-left-radius: var(--radius) !important;
border-top-right-radius: var(--radius) !important; border-top-right-radius: var(--radius) !important;
border-bottom-left-radius: 0 !important; border-bottom-left-radius: 0 !important;
border-bottom-right-radius: 0 !important; border-bottom-right-radius: 0 !important;
} }
.verticalIfMobile.button-group > button:last-of-type { .verticalIfMobile.button-group button:last-of-type {
border-top-left-radius: 0 !important; border-top-left-radius: 0 !important;
border-top-right-radius: 0 !important; border-top-right-radius: 0 !important;
border-bottom-left-radius: var(--radius) !important; border-bottom-left-radius: var(--radius) !important;