Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(svelte): Action Sheet components
- Loading branch information
1 parent
c1907ad
commit cf29c54
Showing
12 changed files
with
277 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<script> | ||
import { | ||
Page, | ||
Navbar, | ||
NavbarBackLink, | ||
BlockTitle, | ||
Block, | ||
Button, | ||
Actions, | ||
ActionsButton, | ||
ActionsLabel, | ||
ActionsGroup, | ||
} from 'konsta/svelte'; | ||
const isPreview = document.location.href.includes('examplePreview'); | ||
let actionsOneOpened = false; | ||
let actionsTwoOpened = false; | ||
</script> | ||
|
||
<Page> | ||
<Navbar title="Action Sheet"> | ||
<svelte:fragment slot="left"> | ||
{#if !isPreview} | ||
<NavbarBackLink onClick={() => history.back()} /> | ||
{/if} | ||
</svelte:fragment> | ||
</Navbar> | ||
|
||
<Block strong class="space-y-4"> | ||
<p> | ||
Action Sheet is a slide-up pane for presenting the user with a set of | ||
alternatives for how to proceed with a given task. | ||
</p> | ||
</Block> | ||
<BlockTitle>Open Action Sheet</BlockTitle> | ||
<Block strong class="flex space-x-4"> | ||
<Button onClick={() => (actionsOneOpened = true)}>One group</Button> | ||
<Button onClick={() => (actionsTwoOpened = true)}>Two groups</Button> | ||
</Block> | ||
|
||
<Actions | ||
opened={actionsOneOpened} | ||
onBackdropClick={() => (actionsOneOpened = false)} | ||
> | ||
<ActionsGroup> | ||
<ActionsLabel>Do something</ActionsLabel> | ||
<ActionsButton onClick={() => (actionsOneOpened = false)} bold> | ||
Button 1 | ||
</ActionsButton> | ||
<ActionsButton onClick={() => (actionsOneOpened = false)}> | ||
Button 2 | ||
</ActionsButton> | ||
<ActionsButton | ||
onClick={() => (actionsOneOpened = false)} | ||
colors={{ text: 'text-red-500' }} | ||
> | ||
Cancel | ||
</ActionsButton> | ||
</ActionsGroup> | ||
</Actions> | ||
|
||
<Actions | ||
opened={actionsTwoOpened} | ||
onBackdropClick={() => (actionsTwoOpened = false)} | ||
> | ||
<ActionsGroup> | ||
<ActionsLabel>Do something</ActionsLabel> | ||
<ActionsButton onClick={() => (actionsTwoOpened = false)} bold> | ||
Button 1 | ||
</ActionsButton> | ||
<ActionsButton onClick={() => (actionsTwoOpened = false)}> | ||
Button 2 | ||
</ActionsButton> | ||
</ActionsGroup> | ||
<ActionsGroup> | ||
<ActionsButton | ||
onClick={() => (actionsTwoOpened = false)} | ||
colors={{ text: 'text-red-500' }} | ||
> | ||
Cancel | ||
</ActionsButton> | ||
</ActionsGroup> | ||
</Actions> | ||
</Page> |
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 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 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 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,29 @@ | ||
<script> | ||
import { ActionsClasses } from '../../shared/classes/ActionsClasses.js'; | ||
import { useThemeClasses } from '../shared/use-theme-classes.js'; | ||
let className = undefined; | ||
export { className as class }; | ||
export let ios = undefined; | ||
export let material = undefined; | ||
export let opened = undefined; | ||
export let backdrop = true; | ||
export let onBackdropClick = undefined; | ||
$: state = opened ? 'opened' : 'closed'; | ||
$: c = useThemeClasses( | ||
{ ios, material }, | ||
ActionsClasses({}), | ||
className, | ||
(v) => (c = v) | ||
); | ||
</script> | ||
|
||
{#if backdrop} | ||
<div class={c.backdrop[state]} on:click={onBackdropClick} /> | ||
{/if} | ||
<div class={c.base[state]} {...$$restProps}> | ||
<slot /> | ||
</div> |
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,71 @@ | ||
<script> | ||
import { ActionsButtonClasses } from '../../shared/classes/ActionsButtonClasses.js'; | ||
import { useThemeClasses } from '../shared/use-theme-classes.js'; | ||
import { useDarkClasses } from '../shared/use-dark-classes.js'; | ||
import { cls } from '../../shared/cls.js'; | ||
import { useTouchRipple } from '../shared/use-touch-ripple.js'; | ||
let className = undefined; | ||
export { className as class }; | ||
let colorsProp = undefined; | ||
export { colorsProp as colors }; | ||
export let ios = undefined; | ||
export let material = undefined; | ||
export let component = 'button'; | ||
export let href = undefined; | ||
export let bold = false; | ||
export let fontSizeIos = 'text-xl'; | ||
export let fontSizeMaterial = 'text-base'; | ||
export let touchRipple = true; | ||
export let hairlines = true; | ||
export let onClick = undefined; | ||
const dark = useDarkClasses(); | ||
$: useTouchRipple(rippleEl, touchRipple); | ||
const rippleEl = { current: null }; | ||
$: attrs = { | ||
href, | ||
...$$restProps, | ||
}; | ||
let Component = component; | ||
if (typeof component === 'undefined' && (href || href === '')) { | ||
Component = 'a'; | ||
} else if (typeof component === 'undefined') { | ||
Component = 'button'; | ||
} | ||
$: colors = { | ||
bg: cls('bg-white', dark('dark:bg-neutral-800')), | ||
activeBg: cls('active:bg-neutral-200', dark('dark:active:bg-neutral-700')), | ||
text: 'text-primary', | ||
...colorsProp, | ||
}; | ||
$: c = useThemeClasses( | ||
{ ios, material }, | ||
ActionsButtonClasses( | ||
{ bold, fontSizeIos, fontSizeMaterial, hairlines }, | ||
colors, | ||
dark | ||
), | ||
className, | ||
(v) => (c = v) | ||
); | ||
</script> | ||
|
||
<svelte:element | ||
this={Component} | ||
bind:this={rippleEl.current} | ||
class={c.base} | ||
on:click={onClick} | ||
{...attrs} | ||
> | ||
<slot /> | ||
</svelte:element> |
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,22 @@ | ||
<script> | ||
import { ActionsGroupClasses } from '../../shared/classes/ActionsGroupClasses.js'; | ||
import { useThemeClasses } from '../shared/use-theme-classes.js'; | ||
let className = undefined; | ||
export { className as class }; | ||
export let ios = undefined; | ||
export let material = undefined; | ||
export let hairlines = true; | ||
$: c = useThemeClasses( | ||
{ ios, material }, | ||
ActionsGroupClasses({ hairlines }), | ||
className, | ||
(v) => (c = v) | ||
); | ||
</script> | ||
|
||
<div class={c.base} {...$$restProps}> | ||
<slot /> | ||
</div> |
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,48 @@ | ||
<script> | ||
import { ActionsLabelClasses } from '../../shared/classes/ActionsLabelClasses.js'; | ||
import { useThemeClasses } from '../shared/use-theme-classes.js'; | ||
import { useDarkClasses } from '../shared/use-dark-classes.js'; | ||
import { cls } from '../../shared/cls.js'; | ||
let className = undefined; | ||
export { className as class }; | ||
let colorsProp = undefined; | ||
export { colorsProp as colors }; | ||
export let ios = undefined; | ||
export let material = undefined; | ||
export let fontSizeIos = 'text-sm'; | ||
export let fontSizeMaterial = 'text-base'; | ||
export let hairlines = true; | ||
const dark = useDarkClasses(); | ||
$: attrs = { | ||
...$$restProps, | ||
}; | ||
$: colors = { | ||
bg: cls('bg-white', dark('dark:bg-neutral-800')), | ||
activeBg: cls('active:bg-neutral-200', dark('dark:active:bg-neutral-700')), | ||
text: cls( | ||
'text-black text-opacity-55', | ||
dark('dark:text-white dark:text-opacity-55') | ||
), | ||
...colorsProp, | ||
}; | ||
$: c = useThemeClasses( | ||
{ ios, material }, | ||
ActionsLabelClasses( | ||
{ fontSizeIos, fontSizeMaterial, hairlines }, | ||
colors, | ||
dark | ||
), | ||
className, | ||
(v) => (c = v) | ||
); | ||
</script> | ||
|
||
<div class={c.base} {...attrs}> | ||
<slot /> | ||
</div> |
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