-
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #179 from perfect-things/multiselect
multiselect
- Loading branch information
Showing
17 changed files
with
449 additions
and
219 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,34 @@ | ||
<pre><code class="language-json">{@html code}</code></pre> | ||
|
||
<script> | ||
import { afterUpdate } from 'svelte'; | ||
export let value =''; | ||
let code =''; | ||
afterUpdate(() => { | ||
requestAnimationFrame(update); | ||
}); | ||
function update () { | ||
if (typeof value !== 'string') value = stringify(value); | ||
code = window.Prism.highlight(value, window.Prism.languages.json, 'json'); | ||
} | ||
function stringify (json) { | ||
if (!json) return ''; | ||
let s = JSON.stringify(json); | ||
s = s.replace(/([:,])/g, '$1 '); | ||
if (s.match(/^{/)) s = s.replace(/{/g, '{ '); | ||
else { | ||
if (s.match(/}/)) s = s.replace(/\]/g, '\n]'); | ||
s = s.replace(/{/g, '\n { '); | ||
} | ||
s = s.replace(/}/g, ' }'); | ||
return s; | ||
} | ||
</script> |
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,2 +1,3 @@ | ||
export { default as CodeExample } from './CodeExample.svelte'; | ||
export { default as CodeBox } from './CodeBox.svelte'; | ||
export { default as JsonBox } from './JsonBox.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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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
Large diffs are not rendered by default.
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
Oops, something went wrong.