-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Access Level control to DocumentUpload
- Loading branch information
1 parent
384399c
commit 8132343
Showing
4 changed files
with
153 additions
and
35 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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<script lang="ts"> | ||
import { | ||
Globe24, | ||
Lock24, | ||
Organization24, | ||
type SvgComponent, | ||
} from "svelte-octicons"; | ||
import Flex from "../common/Flex.svelte"; | ||
interface Level { | ||
value: "private" | "organization" | "public"; | ||
name: string; | ||
description: string; | ||
icon: typeof SvgComponent; | ||
} | ||
const levels: Level[] = [ | ||
{ | ||
value: "private", | ||
name: "Private", | ||
description: "Documents will only be visible to you", | ||
icon: Lock24, | ||
}, | ||
{ | ||
value: "organization", | ||
name: "Organization", | ||
description: "Documents will only be visible to your organization", | ||
icon: Organization24, | ||
}, | ||
{ | ||
value: "public", | ||
name: "Public", | ||
description: "Documents will be publicly visible to everyone", | ||
icon: Globe24, | ||
}, | ||
]; | ||
export let name: string = null; | ||
export let selected: "public" | "organization" | "private" = levels[0].value; | ||
</script> | ||
|
||
<Flex direction="column" gap={0.5}> | ||
{#each levels as { value, name, description, icon }} | ||
<div class="option" class:selected={value === selected}> | ||
<input | ||
class="sr-only" | ||
type="radio" | ||
{name} | ||
id={value} | ||
bind:group={selected} | ||
{value} | ||
/> | ||
<label for={value} class="detail"> | ||
<Flex gap={0.5}> | ||
<svelte:component this={icon} /> | ||
<Flex direction="column" gap={0.125}> | ||
<p class="name">{name}</p> | ||
<p class="description">{description}</p> | ||
</Flex> | ||
</Flex> | ||
</label> | ||
</div> | ||
{/each} | ||
</Flex> | ||
|
||
<style> | ||
.option { | ||
padding: 0.5rem; | ||
border-radius: 0.25rem; | ||
border: 1px solid var(--gray-2, #d8dee2); | ||
background: var(--white); | ||
color: var(--gray-5); | ||
fill: var(--gray-5); | ||
cursor: pointer; | ||
} | ||
.option.selected { | ||
border: 1px solid var(--blue-2, #b5ceed); | ||
background: var(--blue-1, #eef3f9); | ||
color: var(--blue-5); | ||
fill: var(--blue-5); | ||
} | ||
.detail { | ||
cursor: pointer; | ||
} | ||
.name { | ||
font-weight: var(--font-semibold); | ||
} | ||
.description { | ||
font-size: var(--font-xs); | ||
opacity: 0.7; | ||
} | ||
.sr-only { | ||
position: absolute; | ||
clip: rect(1px, 1px, 1px, 1px); | ||
padding: 0; | ||
border: 0; | ||
height: 1px; | ||
width: 1px; | ||
overflow: hidden; | ||
} | ||
</style> |
23 changes: 23 additions & 0 deletions
23
src/lib/components/documents/stories/AccessLevel.stories.svelte
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,23 @@ | ||
<script context="module" lang="ts"> | ||
import { Story, Template } from "@storybook/addon-svelte-csf"; | ||
import AccessLevel from "../AccessLevel.svelte"; | ||
export const meta = { | ||
title: "Components / Documents / Access Level", | ||
component: AccessLevel, | ||
tags: ["autodocs"], | ||
parameters: { layout: "centered" }, | ||
}; | ||
let args = { | ||
level: "private", | ||
}; | ||
</script> | ||
|
||
<Template let:args> | ||
<AccessLevel {...args} /> | ||
</Template> | ||
|
||
<Story name="Private" {args} /> | ||
<Story name="Organization" args={{ ...args, level: "organization" }} /> | ||
<Story name="Public" args={{ ...args, level: "public" }} /> |
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