Skip to content

Commit

Permalink
fix(utils): encodeSearchParams are now exported
Browse files Browse the repository at this point in the history
fix(utils): renamed numberFormatter to formatNumber
fix: updated imports for formatNumber and encodeSearchParams
docs(Navigation): added actions section and placeholder for utilities
  • Loading branch information
Craig Howell authored and Craig Howell committed Oct 12, 2022
1 parent 4a91470 commit c1725a8
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 26 deletions.
27 changes: 23 additions & 4 deletions src/docs/components/navigation/Navigation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@
{
title: 'Toggle',
href: '/toggle'
},
{
title: 'Tooltip',
href: '/tooltip'
}
];
Expand Down Expand Up @@ -231,6 +227,29 @@
{/if}
{/each}
</Menu>
<h3
class="text-xs font-bold text-light-content dark:text-dark-content text-opacity-40 dark:text-opacity-40 mb-2 mt-4"
>
ACTIONS
</h3>
<Menu {active}>
<Menu.Item
key="/tooltip"
label="tooltip"
href="/tooltip"
on:click={() => handleClick('/tooltip')}
/>
</Menu>

<!-- <h3
class="text-xs font-bold text-light-content dark:text-dark-content text-opacity-40 dark:text-opacity-40 mb-2 mt-4"
>
UTILITIES
</h3>
<Menu {active}>
<Menu.Item key="/types" label="Types" href="/types" on:click={() => handleClick('/types')} />
</Menu> -->

<h3
class="text-xs font-bold text-light-content dark:text-dark-content text-opacity-40 dark:text-opacity-40 mb-2 mt-4"
>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/pagination/Pagination.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import HoverBackground from '../HoverBackground.svelte';
import { page } from '$app/stores';
import { encodeSearchParams } from '../../utils/encodeSearchParams';
import { encodeSearchParams } from '../../utils';
export let start: number;
export let end: number;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/slider/Slider.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import numberFormatter from '$lib/utils/numberFormatter';
import { formatNumber } from '../../utils';
export let value = 0;
export let min = 0;
Expand Down Expand Up @@ -31,7 +31,7 @@
<div class="w-full flex justify-between text-xs">
{#each Array(steps) as _, i}
<span
>{numberFormatter((i * step) / 100, {
>{formatNumber((i * step) / 100, {
style: 'percent'
})} |</span
>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils/encodeSearchParams.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function encodeSearchParams(params: { [key: string]: any }): string {
export default function encodeSearchParams(params: { [key: string]: any }): string {
let generatedSearchParams = '?';

for (const [key, value] of Object.entries(params)) {
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions src/lib/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import formatDate from './formatDate';
import numberFormatter from './numberFormatter';
import formatNumber from './formatNumber';
import encodeSearchParams from './encodeSearchParams';

export { formatDate, numberFormatter };
export { formatDate, formatNumber, encodeSearchParams };
32 changes: 16 additions & 16 deletions src/routes/statistic/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { Col, Statistic } from '../../lib';
import numberFormatter from '../../lib/utils/numberFormatter';
import { formatNumber } from '../../lib/utils';
const totalLikes = 25660000;
const totalLikesLastYear = 27660000;
Expand Down Expand Up @@ -30,7 +30,7 @@
<Statistic.Icon slot="icon" icon="favorite" />
<Statistic.Title slot="title">Total Likes</Statistic.Title>
<Statistic.Value slot="value">
{numberFormatter(totalLikes, {
{formatNumber(totalLikes, {
style: 'decimal',
notation: 'compact',
maximumFractionDigits: 1,
Expand All @@ -39,20 +39,20 @@
</Statistic.Value>
<Statistic.Comparison slot="comparison">
<Statistic.Comparison.Value slot="value">
Last Year: {numberFormatter(totalLikesLastYear, {
Last Year: {formatNumber(totalLikesLastYear, {
style: 'decimal',
notation: 'compact',
maximumFractionDigits: 1,
minimumFractionDigits: 1
})}
</Statistic.Comparison.Value>
<Statistic.Comparison.Trend icon="trending_up" slot="trend">
{numberFormatter(getTrendValue(totalLikes, totalLikesLastYear), {
{formatNumber(getTrendValue(totalLikes, totalLikesLastYear), {
style: 'decimal',
notation: 'compact',
maximumFractionDigits: 1,
minimumFractionDigits: 1
})} ({numberFormatter(getTrendPercent(totalLikes, totalLikesLastYear), {
})} ({formatNumber(getTrendPercent(totalLikes, totalLikesLastYear), {
style: 'percent'
})})
</Statistic.Comparison.Trend>
Expand All @@ -65,7 +65,7 @@
<Statistic.Icon slot="icon" icon="assessment" />
<Statistic.Title slot="title">Page Views</Statistic.Title>
<Statistic.Value slot="value">
{numberFormatter(pageViews, {
{formatNumber(pageViews, {
style: 'currency',
notation: 'compact',
maximumFractionDigits: 1,
Expand All @@ -74,20 +74,20 @@
</Statistic.Value>
<Statistic.Comparison slot="comparison">
<Statistic.Comparison.Value slot="value">
Last Year: {numberFormatter(pageViewsLastYear, {
Last Year: {formatNumber(pageViewsLastYear, {
style: 'currency',
notation: 'compact',
maximumFractionDigits: 1,
minimumFractionDigits: 1
})}
</Statistic.Comparison.Value>
<Statistic.Comparison.Trend icon="trending_up" slot="trend">
{numberFormatter(getTrendValue(pageViews, pageViewsLastYear), {
{formatNumber(getTrendValue(pageViews, pageViewsLastYear), {
style: 'currency',
notation: 'compact',
maximumFractionDigits: 1,
minimumFractionDigits: 1
})} ({numberFormatter(getTrendPercent(pageViews, pageViewsLastYear), {
})} ({formatNumber(getTrendPercent(pageViews, pageViewsLastYear), {
style: 'percent'
})})
</Statistic.Comparison.Trend>
Expand All @@ -100,7 +100,7 @@
<Statistic.Icon slot="icon" icon="assessment" />
<Statistic.Title slot="title">New Users</Statistic.Title>
<Statistic.Value slot="value">
{numberFormatter(newUsers, {
{formatNumber(newUsers, {
style: 'decimal',
notation: 'compact',
maximumFractionDigits: 1,
Expand All @@ -116,7 +116,7 @@
<Statistic.Icon class="text-primary" slot="icon" icon="favorite" />
<Statistic.Title slot="title">Total Likes</Statistic.Title>
<Statistic.Value class="text-primary" slot="value">
{numberFormatter(totalLikes, {
{formatNumber(totalLikes, {
style: 'decimal',
notation: 'compact',
maximumFractionDigits: 1,
Expand All @@ -131,7 +131,7 @@
<Statistic.Icon class="text-white" slot="icon" icon="assessment" />
<Statistic.Title class="text-white" slot="title">Page Views</Statistic.Title>
<Statistic.Value class="text-white" slot="value">
{numberFormatter(pageViews, {
{formatNumber(pageViews, {
style: 'currency',
notation: 'compact',
maximumFractionDigits: 1,
Expand All @@ -140,20 +140,20 @@
</Statistic.Value>
<Statistic.Comparison slot="comparison">
<Statistic.Comparison.Value class="text-white" slot="value">
Last Year: {numberFormatter(pageViewsLastYear, {
Last Year: {formatNumber(pageViewsLastYear, {
style: 'currency',
notation: 'compact',
maximumFractionDigits: 1,
minimumFractionDigits: 1
})}
</Statistic.Comparison.Value>
<Statistic.Comparison.Trend class="bg-white text-white" icon="trending_up" slot="trend">
{numberFormatter(getTrendValue(pageViews, pageViewsLastYear), {
{formatNumber(getTrendValue(pageViews, pageViewsLastYear), {
style: 'currency',
notation: 'compact',
maximumFractionDigits: 1,
minimumFractionDigits: 1
})} ({numberFormatter(getTrendPercent(pageViews, pageViewsLastYear), {
})} ({formatNumber(getTrendPercent(pageViews, pageViewsLastYear), {
style: 'percent'
})})
</Statistic.Comparison.Trend>
Expand All @@ -165,7 +165,7 @@
<Statistic>
<Statistic.Title slot="title">New Users</Statistic.Title>
<Statistic.Value slot="value">
{numberFormatter(newUsers, {
{formatNumber(newUsers, {
style: 'decimal',
notation: 'compact',
maximumFractionDigits: 1,
Expand Down

0 comments on commit c1725a8

Please sign in to comment.