-
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
1cfed61
commit 0768bb7
Showing
115 changed files
with
2,976 additions
and
680 deletions.
There are no files selected for viewing
Empty file.
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,49 @@ | ||
import type { MenuProps } from '../lib'; | ||
|
||
export const drilldownMenu: MenuProps = { | ||
groups: { | ||
'level-1': { | ||
divider: true, | ||
}, | ||
'level-2': { | ||
divider: true, | ||
}, | ||
}, | ||
items: [ | ||
{ | ||
id: 'people', | ||
groupId: 'level-1', | ||
size: 'lg', | ||
icon: 'menu-grid', | ||
title: 'Alle skjema', | ||
expanded: true, | ||
items: [ | ||
{ | ||
groupId: 'level-2', | ||
id: 'tema', | ||
icon: 'teddy-bear', | ||
title: 'Tema', | ||
expanded: true, | ||
items: [ | ||
{ | ||
id: 'c1', | ||
groupId: 'level-3', | ||
title: 'Kategori 1', | ||
}, | ||
{ | ||
groupId: 'level-3', | ||
id: 'c2', | ||
title: 'Kategori 2', | ||
selected: true, | ||
}, | ||
{ | ||
groupId: 'level-3', | ||
id: 'c3', | ||
title: 'Kategori 3', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}; |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,22 +1,109 @@ | ||
import { ListItemBase, ListItemHeader, type ListItemInputProps } from '..'; | ||
import { type ChangeEvent, useState } from 'react'; | ||
import { | ||
Button, | ||
type ButtonProps, | ||
Flex, | ||
IconButton, | ||
ListItemBase, | ||
ListItemHeader, | ||
type ListItemInputProps, | ||
Section, | ||
TextField, | ||
type TextFieldProps, | ||
} from '..'; | ||
import { type QueryItemProps, QueryLabel } from './QueryLabel'; | ||
|
||
export interface BookmarksListItemProps extends ListItemInputProps { | ||
id: string; | ||
/** Loading */ | ||
loading?: boolean; | ||
/** Expanded */ | ||
expanded?: boolean; | ||
/** Optional title */ | ||
title?: string; | ||
/** Untitled */ | ||
untitled?: string; | ||
/** Query params */ | ||
params?: QueryItemProps[]; | ||
/** Toggle function */ | ||
onToggle?: () => void; | ||
/** Title field */ | ||
titleField?: TextFieldProps; | ||
/** Save button */ | ||
saveButton?: ButtonProps; | ||
/** Delete button */ | ||
removeButton?: ButtonProps; | ||
} | ||
|
||
export const BookmarksListItem = ({ size = 'sm', title, description, params, ...rest }: BookmarksListItemProps) => { | ||
interface FormData { | ||
title?: string; | ||
params?: QueryItemProps[]; | ||
} | ||
|
||
export const BookmarksListItem = ({ | ||
size = 'sm', | ||
icon = 'bookmark', | ||
expanded, | ||
loading, | ||
title, | ||
titleField, | ||
untitled = 'Untitled bookmark', | ||
params, | ||
onToggle, | ||
saveButton, | ||
removeButton, | ||
...rest | ||
}: BookmarksListItemProps) => { | ||
const [formData, setFormData] = useState<FormData>({ title, params }); | ||
|
||
const onChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
const { name, value } = event.target; | ||
setFormData((prevState) => ({ | ||
...prevState, | ||
[name]: value, | ||
})); | ||
}; | ||
|
||
if (expanded && !loading) { | ||
return ( | ||
<ListItemBase loading={loading} expanded={expanded}> | ||
<ListItemHeader | ||
size={size} | ||
title={title || untitled} | ||
loading={loading} | ||
icon={icon} | ||
onClick={onToggle} | ||
controls={<IconButton variant="outline" size="sm" icon="chevron-up" onClick={onToggle} />} | ||
{...rest} | ||
/> | ||
{expanded && ( | ||
<Section padding="lg" spacing="lg"> | ||
<QueryLabel params={params} /> | ||
{titleField && <TextField {...titleField} name="title" value={formData?.title || ''} onChange={onChange} />} | ||
{(saveButton || removeButton) && ( | ||
<Flex as="footer" direction="row" spacing="sm"> | ||
{saveButton && <Button {...saveButton} />} | ||
{removeButton && <Button {...removeButton} variant="outline" />} | ||
</Flex> | ||
)} | ||
</Section> | ||
)} | ||
</ListItemBase> | ||
); | ||
} | ||
|
||
return ( | ||
<ListItemBase {...rest}> | ||
{!title && ( | ||
<ListItemHeader size={size} title={title} linkIcon="chevron-right" {...rest}> | ||
<QueryLabel params={params} /> | ||
</ListItemHeader> | ||
)} | ||
<ListItemBase {...rest} loading={loading} expanded={expanded}> | ||
<ListItemHeader | ||
size={size} | ||
title={title} | ||
loading={loading} | ||
icon={icon} | ||
controls={!loading && <IconButton variant="outline" size="sm" icon="chevron-down" onClick={onToggle} />} | ||
{...rest} | ||
> | ||
{!title && !loading && <QueryLabel params={params} />} | ||
</ListItemHeader> | ||
</ListItemBase> | ||
); | ||
}; |
Oops, something went wrong.