Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions platforms/metagram/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
--color-grey: #f5f5f5;
--color-red: #ff5255;

--color-gray-200: #eaecf0;

--color-brand-burnt-orange: #da4a11;
--color-brand-burnt-orange-100: #f8dbcf;
--color-brand-burnt-orange-200: #f3c3b0;
Expand Down
16 changes: 16 additions & 0 deletions platforms/metagram/src/lib/ui/Toggle/Toggle.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { ComponentProps } from 'svelte';
import Toggle from './Toggle.svelte';

export default {
title: 'UI/Toggle',
component: Toggle,
tags: ['autodocs'],
render: (args: { Component: Toggle; props: ComponentProps<typeof Toggle> }) => ({
Component: Toggle,
props: args
})
};

export const Primary = {
args: {}
};
21 changes: 21 additions & 0 deletions platforms/metagram/src/lib/ui/Toggle/Toggle.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';

interface IToggleProps extends HTMLAttributes<HTMLElement> {
checked: boolean;
}

let { checked = $bindable(false), ...restProps }: IToggleProps = $props();

let uniqueId = Math.random().toString().split('.')[1];
</script>

<label {...restProps} for={uniqueId} class="relative">
<div class="h-6 w-11 rounded-full bg-gray-200 transition duration-300">
<div
class={`absolute top-0.5 left-0.5 h-5 w-5 rounded-full ${checked ? 'bg-brand-burnt-orange translate-x-5' : 'translate-x-0 bg-white'} transition duration-300`}
></div>
</div>
</label>

<input id={uniqueId} type="checkbox" bind:checked class="hidden" tabindex="0" />
1 change: 1 addition & 0 deletions platforms/metagram/src/lib/ui/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as Button } from './Button/Button.svelte';
export { default as Avatar } from './Avatar/Avatar.svelte';
export { default as Input } from './Input/Input.svelte';
export { default as Toggle } from './Toggle/Toggle.svelte';
Loading