-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add string utils to top-level exports and add docs
- Loading branch information
Showing
5 changed files
with
74 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte-ux': patch | ||
--- | ||
|
||
Add string utils to top-level exports and add docs |
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
55 changes: 55 additions & 0 deletions
55
packages/svelte-ux/src/routes/docs/utils/string/+page.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,55 @@ | ||
<script lang="ts"> | ||
import Preview from '$lib/components/Preview.svelte'; | ||
import { uniqueId, truncate, toTitleCase } from '$lib/utils/string'; | ||
import Code from '$lib/components/Code.svelte'; | ||
import RangeField from '$lib/components/RangeField.svelte'; | ||
let str = 'This is very long text that will be truncated'; | ||
let totalChars = 20; | ||
let endChars = 5; | ||
</script> | ||
|
||
<h1>Usage</h1> | ||
|
||
<Code | ||
source={`import { uniqueId, truncate, toTitleCase } from 'svelte-ux';`} | ||
language="javascript" | ||
class="mb-4" | ||
/> | ||
|
||
<h1>Examples</h1> | ||
|
||
<h2>truncate()</h2> | ||
|
||
<Code source={`import { truncate } from 'svelte-ux';`} language="javascript" class="mb-4" /> | ||
|
||
<h3>Playground</h3> | ||
<div class="grid grid-cols-2 gap-2 mb-2"> | ||
<RangeField label="Total chars" bind:value={totalChars} /> | ||
<RangeField label="End chars" bind:value={endChars} /> | ||
</div> | ||
<Preview> | ||
<div>{truncate(str, totalChars, endChars)}</div> | ||
</Preview> | ||
|
||
<h3>Total only</h3> | ||
<Preview> | ||
<div>{truncate(str, 20)}</div> | ||
</Preview> | ||
|
||
<h3>Middle ellipsis</h3> | ||
<Preview> | ||
<div>{truncate(str, 20, 10)}</div> | ||
</Preview> | ||
|
||
<h2>unique()</h2> | ||
|
||
<Code source={`import { uniqueId } from 'svelte-ux';`} language="javascript" class="mb-4" /> | ||
|
||
<h3>Basic</h3> | ||
<Preview> | ||
<div>{uniqueId('checkbox-')}</div> | ||
<div>{uniqueId('checkbox-')}</div> | ||
<div>{uniqueId('checkbox-')}</div> | ||
<div>{uniqueId('radio-')}</div> | ||
</Preview> |
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,12 @@ | ||
import source from '$lib/utils/string.ts?raw'; | ||
import pageSource from './+page.svelte?raw'; | ||
|
||
export async function load() { | ||
return { | ||
meta: { | ||
source, | ||
pageSource, | ||
description: 'String utilities', | ||
}, | ||
}; | ||
} |
c046b08
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
svelte-ux – ./
svelte-ux-techniq-team.vercel.app
svelte-ux-git-main-techniq-team.vercel.app
svelte-ux.vercel.app
svelte-ux.techniq.dev