-
Notifications
You must be signed in to change notification settings - Fork 4
feat: FileInput #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: FileInput #150
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f6c1ce8
feat: FileInput
grv-saini-20 ac9c6aa
fix: added icon
grv-saini-20 513d103
feat: cancel upload
grv-saini-20 cd540cd
fix: remove redundant code
grv-saini-20 2beb5fe
fix: usage docs added and as per requirements
grv-saini-20 e48e3a2
fix: moved to framents
grv-saini-20 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
platforms/metagram/src/lib/ui/InputFile/InputFile.stories.ts
This file contains hidden or 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,15 @@ | ||
import { InputFile } from '..'; | ||
|
||
export default { | ||
title: 'UI/InputFile', | ||
component: InputFile, | ||
tags: ['autodocs'], | ||
render: (args: { type: string; placeholder: string; helperText: string }) => ({ | ||
Component: InputFile, | ||
props: args | ||
}) | ||
}; | ||
|
||
export const Main = { | ||
args: {} | ||
}; |
This file contains hidden or 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,46 @@ | ||
<script lang="ts"> | ||
import { Album01Icon } from '@hugeicons/core-free-icons'; | ||
import { HugeiconsIcon } from '@hugeicons/svelte'; | ||
|
||
interface IInputFileProps { | ||
files: FileList | undefined; | ||
placeholder: string; | ||
} | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
let { files = $bindable() }: IInputFileProps = $props(); | ||
|
||
const uniqueId = Math.random().toString().split('.')[1]; | ||
let inputFile: HTMLInputElement | undefined = $state(); | ||
|
||
function cancelUpload(e: MouseEvent) { | ||
e.preventDefault(); | ||
if (inputFile) inputFile.value = ''; | ||
files = undefined; | ||
} | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
</script> | ||
|
||
<input id={uniqueId} type="file" bind:files class="hidden" accept="image/*" bind:this={inputFile} /> | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
<label | ||
for={uniqueId} | ||
class="bg-grey text-black-400 font-geist flex h-[158px] w-full items-center justify-center rounded-4xl text-base font-normal" | ||
> | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
{#if files} | ||
<div class="flex flex-col items-center gap-2"> | ||
<HugeiconsIcon size="24px" icon={Album01Icon} color="var(--color-black-600)" /> | ||
<h3 class="text-black-800">{files[0].name.slice(0, 10) + '...'}</h3> | ||
<button | ||
type="button" | ||
onclick={(e) => cancelUpload(e)} | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
class="text-brand-burnt-orange underline decoration-solid" | ||
> | ||
Delete Upload | ||
</button> | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
</div> | ||
{:else} | ||
<div class="flex flex-col items-center gap-2"> | ||
<HugeiconsIcon size="24px" icon={Album01Icon} color="var(--color-black-600)" /> | ||
Click to upload a photo | ||
</div> | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
{/if} | ||
</label> |
This file contains hidden or 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,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 InputFile } from './InputFile/InputFile.svelte'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.