0.0.3 • Published 1 year ago

epfn-sveltekit-components v0.0.3

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

EPFN Components for SvelteKit

Opinionated SvelteKit components for my personal purposes.

Installation

npm i epfn-sveltekit-components

Import component

<script>
	import { Drawer } from 'epfn-sveltekit-components';
</script>

Recommendation

Components have no CSS reset, use Tailwind: https://tailwindcss.com/docs/guides/sveltekit

Drawer

Headless-like side appearing drawer with backdrop. You must provide content (with styles) for button and drawer via slots. Button position is controlled by putting Drawer Component anywhere you like. Drawer position is controlled via position prop.

Props

propdescriptiontypedefault value
widthwidth of drawer in pxnumber260
positionposition of drawer"left", "right""left"
durationduration of drawer animation in msnumber150

Slots

slotdescription
button-opencontent inside button when drawer is not visible, usually "hamburger" icon
button-closecontent inside button when drawer is visible, usually "x" icon
contentcontent inside drawer

Styling

CSS variabledescriptionfallback value
--backdrop-colorcolor of backdroprgba(0, 0, 0, 0.75)

Additional features

You can close drawer from child component via closeDrawer callback from context:

<script lang="ts">
	import { getContext } from 'svelte';
	const { closeDrawer } = getContext<{ closeDrawer: () => void }>('closeDrawer');
</script>

MenuDrawer

Vertical list of links with border between for drawer. Clicks on links closing drawer.

Props

propdescriptiontypedefault value
linksarray of links{ href: string; label: string }[]

Styling

CSS variabledescriptionfallback value
--border-colorcolor of border between list itemsgray

MenuHeader

Horizontal list of links with underline on hover.

Props

propdescriptiontypedefault value
linksarray of links{ href: string; label: string }[]

Styling

CSS variabledescriptionfallback value
--underline-thicknessthickness of underline2px
--underline-offsetoffset of underline20px
--underline-colorcolor of underlinegray

Spinner

Usual animated spinner

Styling

CSS variabledescriptionfallback value
--spinner-colorcolor of spinnerwhite

Alerts

Vertical list of animated alerts

Props

propdescriptiontypedefault value
itemsarray of alerts{ text: string; type: 'success' | 'error' | 'warning' }[]
durationduration of alert animation in msnumber200

Styling

You can apply additional styling from parent with data attributes: data-type for all items, data-type='success' for type "success", data-type='error' for type "error", data-type='warning' for type "warning"

CSS variabledescriptionfallback value
--background-colorcolor of alert itemwhite
--svg-colorcolor of alert item icongray

FieldText, FieldEmail, FieldPassword, FieldTextarea, FieldCheckbox

Inputs with label

propdescriptiontypedefault value
valuevalue for input bindingstring""
labeltext for labelstring
nametext for input name attributestring
requiredvalue for input required attributebooleanfalse
readonlyvalue for input readonly attributebooleanfalse
errorvalue for input aria-invalid attributebooleanfalse
hiddenif true checkbox is hiddenbooleanfalse
rowsvalue for textarea rows attributenumber8

Styling

CSS variabledescriptionfallback value
--background-colorcolor of input backgroundwhite
--border-colorcolor of input border and outline colorgray
--svg-colorcolor of input password svg elementgray
0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago