-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1353 from appwrite/feat-new-multipart-progressbar
Feat new multipart progressbar
- Loading branch information
Showing
13 changed files
with
216 additions
and
66 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 |
---|---|---|
|
@@ -153,4 +153,6 @@ dist | |
|
||
# Sentry Config File | ||
.sentryclirc | ||
.idea | ||
|
||
# IDE specifics | ||
.idea |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,36 +1,36 @@ | ||
<script lang="ts"> | ||
export let currentValue: string; | ||
export let currentUnit: string; | ||
export let maxValue: string; | ||
export let maxUnit: string; | ||
import { ProgressBar, type ProgressbarData } from '$lib/components/progressbar'; | ||
export let currentValue: string | undefined = undefined; | ||
export let currentUnit: string | undefined = undefined; | ||
export let maxValue: string | undefined = undefined; | ||
export let maxUnit: string | undefined = undefined; | ||
export let progressValue: number; | ||
export let progressMax: number; | ||
export let showBar = true; | ||
export let minimum = 0; | ||
export let maximum = 100; | ||
export let progressBarData: Array<ProgressbarData> = []; | ||
$: progress = Math.round((progressValue / progressMax) * 100); | ||
</script> | ||
|
||
<section class="progress-bar"> | ||
<div class="u-flex u-flex-vertical"> | ||
<div class="u-flex u-main-space-between"> | ||
<p> | ||
<span class="heading-level-4">{currentValue}</span> | ||
<span class="body-text-1 u-bold">{currentUnit}</span> | ||
{#if currentValue !== undefined && currentUnit !== undefined && progress !== undefined && maxValue !== undefined && maxUnit !== undefined} | ||
<div class="u-flex u-flex-vertical"> | ||
<div class="u-flex u-main-space-between"> | ||
<p> | ||
<span class="heading-level-4">{currentValue}</span> | ||
<span class="body-text-1 u-bold">{currentUnit}</span> | ||
</p> | ||
<p class="heading-level-4">{progress}%</p> | ||
</div> | ||
|
||
<p class="body-text-2"> | ||
{maxValue} | ||
{maxUnit} | ||
</p> | ||
<p class="heading-level-4">{progress}%</p> | ||
</div> | ||
<p class="body-text-2"> | ||
{maxValue} | ||
{maxUnit} | ||
</p> | ||
</div> | ||
{#if showBar} | ||
<div | ||
class="progress-bar-container u-margin-block-start-16" | ||
class:is-warning={progress >= 75 && progress < 100} | ||
class:is-danger={progress >= 100} | ||
style:--graph-size={Math.max(Math.min(progress, maximum), minimum) + '%'} /> | ||
{/if} | ||
{#if showBar && progressBarData.length > 0} | ||
<ProgressBar maxSize={progressMax} data={progressBarData} /> | ||
{/if} | ||
</section> |
File renamed without changes.
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,92 @@ | ||
<script lang="ts"> | ||
import { tooltip } from '$lib/actions/tooltip'; | ||
import type { ProgressbarData, ProgressbarProps } from '$lib/components'; | ||
type $$Props = ProgressbarProps; | ||
/** | ||
* The max value of the progressbar | ||
*/ | ||
export let maxSize: $$Props['maxSize']; | ||
/** | ||
* The data for the progressbar | ||
*/ | ||
export let data: $$Props['data']; | ||
/** | ||
* The remaining value of the progressbar | ||
*/ | ||
$: remainder = data.reduce((sum: number, item: ProgressbarData) => sum - item.size, maxSize); | ||
</script> | ||
|
||
<section class="progressbar__container"> | ||
{#each $$props.data as item} | ||
<div | ||
class="progressbar__content" | ||
style:background-color={item.color} | ||
style:width={`${(item.size / maxSize) * 100}%`} | ||
use:tooltip={{ | ||
disabled: !item.tooltip, | ||
allowHTML: true, | ||
content: `<span class="u-bold">${item.tooltip.title}</span> ${item.tooltip.label}` | ||
}}> | ||
</div> | ||
{/each} | ||
{#if remainder > 0} | ||
<div class="progressbar__content" style:width={`${(remainder / maxSize) * 100}%`} /> | ||
{/if} | ||
</section> | ||
|
||
<style lang="scss"> | ||
:root { | ||
--progressbar-border-radius: 0.25rem; | ||
--progressbar-tooltip-label-color: #818186; | ||
--progressbar-tooltip-link-color: #6c6c71; | ||
} | ||
:global(.theme-dark) { | ||
--progressbar-background-color: var(--neutral-800, #2d2d31); | ||
--progressbar-tooltip-background-color: var(--neutral-800, #2d2d31); | ||
--progressbar-tooltip-border-color: var(--neutral-80, #424248); | ||
} | ||
:global(.theme-light) { | ||
--progressbar-background-color: var(--neutral-40, #f4f4f7); | ||
--progressbar-tooltip-background-color: #ffffff; | ||
--progressbar-tooltip-border-color: #ededf0; | ||
} | ||
.progressbar { | ||
&__container { | ||
height: 0.5rem; | ||
background-color: var(--progressbar-background-color); | ||
border-radius: var(--progressbar-border-radius); | ||
display: flex; | ||
flex-direction: row; | ||
gap: 2px; | ||
} | ||
&__content { | ||
height: 100%; | ||
min-width: 4px; | ||
display: flex; | ||
justify-content: center; | ||
&::before { | ||
content: ''; | ||
height: 2.5rem; | ||
margin-top: -1.25rem; | ||
width: 100%; | ||
} | ||
&:first-child { | ||
border-top-left-radius: var(--progressbar-border-radius); | ||
border-bottom-left-radius: var(--progressbar-border-radius); | ||
} | ||
&:last-child { | ||
border-top-right-radius: var(--progressbar-border-radius); | ||
border-bottom-right-radius: var(--progressbar-border-radius); | ||
} | ||
} | ||
} | ||
</style> |
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,17 @@ | ||
export type ProgressbarData = { | ||
size: number; | ||
color: string; | ||
tooltip?: { | ||
title: string; | ||
label: string; | ||
// linkTitle?: string; | ||
// linkPath?: string; | ||
}; | ||
}; | ||
|
||
export type ProgressbarProps = { | ||
maxSize: number; | ||
data: Array<ProgressbarData>; | ||
}; | ||
|
||
export { default as ProgressBar } from './ProgressBar.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
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
Oops, something went wrong.