refactor: format and lint codebase (#971)

This commit is contained in:
Aman Harwara
2022-04-13 22:02:34 +05:30
committed by GitHub
parent dc9c1ea0fc
commit 8e467f9e6d
367 changed files with 13778 additions and 16093 deletions

View File

@@ -0,0 +1,40 @@
import { FunctionalComponent } from 'preact'
import { useRef, useState } from 'preact/hooks'
import { ArrowDownCheckmarkIcon } from '@standardnotes/stylekit'
import { Title } from '@/Components/Preferences/PreferencesComponents'
type Props = {
title: string | JSX.Element
className?: string
}
export const AccordionItem: FunctionalComponent<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>
)
}

View File

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

View File

@@ -0,0 +1,72 @@
import { FunctionComponent } from 'preact'
import {
AlertDialog,
AlertDialogDescription,
AlertDialogLabel,
} from '@node_modules/@reach/alert-dialog'
import { useRef } from '@node_modules/preact/hooks'
export 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 const ModalDialogLabel: FunctionComponent<{
closeDialog: () => void
className?: string
}> = ({ 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 const ModalDialogDescription: FunctionComponent<{
className?: string
}> = ({ children, className = '' }) => (
<AlertDialogDescription className={`px-4 py-4 flex flex-row items-center ${className}`}>
{children}
</AlertDialogDescription>
)
export const ModalDialogButtons: FunctionComponent<{ className?: string }> = ({
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 ModalDialog