refactor: repo (#1070)

This commit is contained in:
Mo
2022-06-07 07:18:41 -05:00
committed by GitHub
parent 4c65784421
commit f4ef63693c
1102 changed files with 5786 additions and 3366 deletions

View File

@@ -0,0 +1,37 @@
import { FunctionComponent, useRef, useState } from 'react'
import { ArrowDownCheckmarkIcon } from '@standardnotes/icons'
import { Title } from '@/Components/Preferences/PreferencesComponents/Content'
type Props = {
title: string | JSX.Element
className?: string
}
const AccordionItem: FunctionComponent<Props> = ({ title, className = '', children }) => {
const elementRef = useRef<HTMLDivElement>(null)
const [isExpanded, setIsExpanded] = useState(false)
return (
<div className={className}>
<div
className={'relative flex cursor-pointer hover:underline'}
onClick={() => {
setIsExpanded(!isExpanded)
}}
>
<Title>{title}</Title>
<ArrowDownCheckmarkIcon
className={'sn-accordion-arrow-icon absolute right-0'}
width={20}
height={20}
data-is-expanded={isExpanded}
/>
</div>
<div className={'accordion-contents-container cursor-auto'} data-is-expanded={isExpanded} ref={elementRef}>
{children}
</div>
</div>
)
}
export default AccordionItem

View File

@@ -0,0 +1,10 @@
import { FunctionComponent } from 'react'
type Props = {
classes?: string
}
const HorizontalSeparator: FunctionComponent<Props> = ({ classes = '' }) => {
return <hr className={`h-1px w-full bg-border no-border ${classes}`} />
}
export default HorizontalSeparator

View File

@@ -0,0 +1,22 @@
import { FunctionComponent, useRef } from 'react'
import { AlertDialog } from '@reach/alert-dialog'
const ModalDialog: FunctionComponent = ({ children }) => {
const ldRef = useRef<HTMLButtonElement>(null)
return (
<AlertDialog leastDestructiveRef={ldRef}>
{/* sn-component is focusable by default, but doesn't stretch to child width
resulting in a badly focused dialog. Utility classes are not available
at the sn-component level, only below it. tabIndex -1 disables focus
and enables it on the child component */}
<div tabIndex={-1} className="sn-component">
<div tabIndex={0} className="sk-panel w-160 bg-default rounded shadow-overlay focus:padded-ring-info">
{children}
</div>
</div>
</AlertDialog>
)
}
export default ModalDialog

View File

@@ -0,0 +1,23 @@
import { FunctionComponent } from 'react'
type Props = {
className?: string
}
const ModalDialogButtons: FunctionComponent<Props> = ({ children, className }) => (
<>
<hr className="h-1px bg-border no-border m-0" />
<div className={`px-4 py-4 flex flex-row items-center ${className}`}>
{children != undefined && Array.isArray(children)
? children.map((child, idx, arr) => (
<>
{child}
{idx < arr.length - 1 ? <div className="min-w-3" /> : undefined}
</>
))
: children}
</div>
</>
)
export default ModalDialogButtons

View File

@@ -0,0 +1,14 @@
import { FunctionComponent } from 'react'
import { AlertDialogDescription } from '@reach/alert-dialog'
type Props = {
className?: string
}
const ModalDialogDescription: FunctionComponent<Props> = ({ children, className = '' }) => (
<AlertDialogDescription className={`px-4 py-4 flex flex-row items-center ${className}`}>
{children}
</AlertDialogDescription>
)
export default ModalDialogDescription

View File

@@ -0,0 +1,21 @@
import { FunctionComponent } from 'react'
import { AlertDialogLabel } from '@reach/alert-dialog'
type Props = {
closeDialog: () => void
className?: string
}
const ModalDialogLabel: FunctionComponent<Props> = ({ children, closeDialog, className }) => (
<AlertDialogLabel className={`sk-panel-header px-4.5 ${className}`}>
<div className="w-full flex flex-row justify-between items-center">
<div className="flex-grow color-text text-base font-medium">{children}</div>
<div tabIndex={0} className="font-bold color-info cursor-pointer" onClick={closeDialog}>
Close
</div>
</div>
<hr className="h-1px bg-border no-border m-0" />
</AlertDialogLabel>
)
export default ModalDialogLabel