chore: move all components into Components dir with pascal case (#934)
This commit is contained in:
44
app/assets/javascripts/components/Shared/AccordionItem.tsx
Normal file
44
app/assets/javascripts/components/Shared/AccordionItem.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
import { FunctionalComponent } from 'preact';
|
||||
import { useRef, useState } from 'preact/hooks';
|
||||
import { ArrowDownCheckmarkIcon } from '@standardnotes/stylekit';
|
||||
import { Title } from '@/components/Preferences/components';
|
||||
|
||||
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>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
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}`} />;
|
||||
};
|
||||
80
app/assets/javascripts/components/Shared/ModalDialog.tsx
Normal file
80
app/assets/javascripts/components/Shared/ModalDialog.tsx
Normal file
@@ -0,0 +1,80 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user