-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4990ff0
commit c7018ba
Showing
20 changed files
with
968 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
export * from './components/file-upload/components/file-delete-button'; | ||
export * from './components/file-upload/components/file-upload-button'; | ||
export * from './components/file-upload/components/file-upload-input'; | ||
export * from './components/file-upload/document-file-upload'; | ||
export * from './components/file-upload/image-file-upload'; | ||
export * from './components/action-box-item'; | ||
export * from './components/alert'; | ||
export * from './components/editor'; | ||
export * from './components/field-image'; | ||
export * from './components/labeled-button'; | ||
export * from './components/modal'; | ||
export * from './components/select-alt'; | ||
export * from './components/select-option'; | ||
export * from './components/select'; | ||
export * from './components/tag-field'; | ||
export * from './components/tag-select'; | ||
export * from './breadcrumb'; | ||
export * from './list-item'; | ||
export * from './table'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { ReactNode } from 'react'; | ||
import { ButtonProps, Container, Flex, Grid } from 'theme-ui'; | ||
|
||
export interface ActionBoxItemProps extends ButtonProps { | ||
actions?: Array<ReactNode>; | ||
} | ||
|
||
export const ActionBoxItem: React.FC<ActionBoxItemProps> = ({ | ||
actions, | ||
disabled, | ||
children, | ||
}) => { | ||
return ( | ||
<Container | ||
sx={{ | ||
color: disabled ? 'secondary' : 'primary', | ||
border: '5px solid', | ||
borderColor: 'muted', | ||
borderRadius: '8px', | ||
p: 3, | ||
m: 2, | ||
}} | ||
> | ||
<Flex sx={{ alignItems: 'center' }}> | ||
<Grid gap={2} columns={[1, 6, 6, 10]} sx={{ flexGrow: 1 }}> | ||
{children} | ||
</Grid> | ||
{actions} | ||
</Flex> | ||
</Container> | ||
); | ||
}; | ||
|
||
ActionBoxItem.displayName = 'ListBox'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import { | ||
Alert as AlertTheme, | ||
AlertProps as AlertThemeProps, | ||
Close, | ||
} from 'theme-ui'; | ||
|
||
export interface AlertProps { | ||
onClose?: () => void; | ||
} | ||
|
||
export const Alert: React.FC<AlertProps & AlertThemeProps> = ({ | ||
children, | ||
onClose, | ||
...rest | ||
}) => ( | ||
<AlertTheme {...rest} sx={{ position: 'relative', mb: 3 }}> | ||
{children} | ||
<Close sx={{ position: 'absolute', right: 10, top: 10 }} onClick={onClose} /> | ||
</AlertTheme> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React, { useMemo, useState } from 'react'; | ||
import { Node, createEditor } from 'slate'; | ||
import { Editable, Slate, withReact } from 'slate-react'; | ||
import { ForwardRef } from 'theme-ui'; | ||
|
||
export interface EditorProps { | ||
text: Node[]; | ||
onChange?: (value: Node[]) => void; | ||
} | ||
|
||
const noteDefaultValue = [ | ||
{ | ||
type: 'paragraph', | ||
children: [{ text: '' }], | ||
}, | ||
]; | ||
|
||
export const Editor: ForwardRef<HTMLInputElement, EditorProps> = | ||
React.forwardRef(({ text = noteDefaultValue, onChange = () => '' }, ref) => { | ||
const editor = useMemo(() => withReact(createEditor()), []); | ||
const [editorValue, setEditorValue] = useState(text); | ||
|
||
return ( | ||
<Slate | ||
editor={editor} | ||
value={editorValue} | ||
onChange={val => { | ||
onChange(val); | ||
setEditorValue(val); | ||
}} | ||
ref={ref} | ||
> | ||
<Editable | ||
sx={{ | ||
mt: 3, | ||
minHeight: '160px', | ||
}} | ||
/> | ||
</Slate> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import React from 'react'; | ||
import { HiOutlineUser } from 'react-icons/hi'; | ||
import { | ||
Box, | ||
Label, | ||
Input, | ||
FieldProps, | ||
Text, | ||
Image, | ||
Flex, | ||
ForwardRef, | ||
InputProps, | ||
ThemeUIStyleObject, | ||
} from 'theme-ui'; | ||
import { getMargin, getPos, omitMargin, omitPos } from '../util'; | ||
|
||
export interface UserProps { | ||
photoUrl: string; | ||
firstName: string; | ||
lastName: string; | ||
roles: string[]; | ||
} | ||
|
||
// TODO correctly type this interface and implement it to type props | ||
export interface FieldImageProps { | ||
as: ForwardRef<any, InputProps>; | ||
label: string; | ||
name: string; | ||
error: any; | ||
sx: ThemeUIStyleObject; | ||
userData: Partial<UserProps>; | ||
children: any; | ||
} | ||
|
||
export const FieldImage = React.forwardRef( | ||
( | ||
{ as: Control = Input, label, name, error, sx, userData, ...props }: FieldProps<any>, | ||
ref | ||
) => { | ||
return ( | ||
<Flex | ||
{...getMargin(props)} | ||
sx={{ | ||
p: 3, | ||
mt: 3, | ||
mb: 3, | ||
borderRadius: '8px', | ||
border: '3px solid', | ||
borderColor: 'primary', | ||
backgroundColor: 'background', | ||
...getPos(sx), | ||
}} | ||
> | ||
<Flex | ||
sx={{ | ||
width: '48px', | ||
height: '48px', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
border: '2px dashed', | ||
borderRadius: '50%', | ||
borderColor: 'accent', | ||
mr: 4, | ||
fontSize: '20px', | ||
}} | ||
> | ||
{/* TODO: replace with Avatar component (shows user image or initials) */} | ||
{userData ? ( | ||
<Image | ||
src={ | ||
userData?.photoUrl || | ||
`https://eu.ui-avatars.com/api/?name=${userData?.firstName}+${userData?.lastName}&background=749F97&size=512` | ||
} | ||
variant="rounded" | ||
sx={{ minWidth: 52, width: 52, height: 52 }} | ||
/> | ||
) : ( | ||
<HiOutlineUser /> | ||
)} | ||
</Flex> | ||
<Box sx={{ flexGrow: 1 }}> | ||
<Label sx={{ fontWeight: 'bold', fontSize: 1 }} htmlFor={name}> | ||
{label} | ||
</Label> | ||
<Control | ||
ref={ref} | ||
id={name} | ||
name={name} | ||
sx={{ border: 0, outline: 'none', p: 0, ...omitPos(sx) }} | ||
{...omitMargin(props)} | ||
/> | ||
{!!error && <Text sx={{ color: 'lightRed' }}>{error}</Text>} | ||
</Box> | ||
</Flex> | ||
); | ||
} | ||
); |
16 changes: 16 additions & 0 deletions
16
src/components/file-upload/components/file-delete-button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import { Button, ButtonProps } from 'theme-ui'; | ||
|
||
export const FileDeleteButton: React.FC<ButtonProps> = ({ children, ...props }) => ( | ||
<Button | ||
variant="danger" | ||
type="button" | ||
sx={{ | ||
display: 'inline-flex', | ||
alignItems: 'center', | ||
}} | ||
{...props} | ||
> | ||
{children} | ||
</Button> | ||
); |
34 changes: 34 additions & 0 deletions
34
src/components/file-upload/components/file-upload-button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import { FiLoader } from 'react-icons/fi'; | ||
import { HiOutlineUpload } from 'react-icons/hi'; | ||
import { Button, ButtonProps } from 'theme-ui'; | ||
|
||
export type FileUploadButtonProps = { | ||
loading?: boolean; | ||
} & ButtonProps; | ||
|
||
export const FileUploadButton: React.FC<FileUploadButtonProps> = ({ | ||
loading, | ||
children, | ||
...props | ||
}) => ( | ||
<Button | ||
variant="secondary" | ||
type="button" | ||
sx={{ | ||
display: 'inline-flex', | ||
alignItems: 'center', | ||
color: 'text', | ||
borderColor: 'text', | ||
}} | ||
disabled={loading} | ||
{...props} | ||
> | ||
{children} | ||
{!loading ? ( | ||
<HiOutlineUpload size={16} sx={{ ml: 2 }} /> | ||
) : ( | ||
<FiLoader sx={{ height: '1rem', ml: 2 }} /> | ||
)} | ||
</Button> | ||
); |
11 changes: 11 additions & 0 deletions
11
src/components/file-upload/components/file-upload-input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
|
||
export interface FileUploadInputProps extends React.HTMLProps<HTMLInputElement> { | ||
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void; | ||
inputRef: { current: null | HTMLInputElement }; | ||
} | ||
|
||
export const FileUploadInput: React.FC<FileUploadInputProps> = ({ | ||
inputRef, | ||
...rest | ||
}) => <input ref={inputRef} {...rest} type="file" sx={{ display: 'none' }} />; |
Oops, something went wrong.