forked from storybookjs/storybook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4261b15
commit 11f6dfa
Showing
6 changed files
with
226 additions
and
28 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,46 @@ | ||
import svelteDoc from 'sveltedoc-parser'; | ||
import * as fs from 'fs'; | ||
import { createArgTypes } from './extractArgTypes'; | ||
|
||
const content = fs.readFileSync(`${__dirname}/sample/MockButton.svelte`, 'utf-8'); | ||
|
||
describe('Extracting Arguments', () => { | ||
it('should create ArgTypes', async () => { | ||
const doc = await svelteDoc.parse({ fileContent: content, version: 3 }); | ||
|
||
const results = createArgTypes(doc); | ||
|
||
expect(results).toMatchInlineSnapshot(` | ||
Object { | ||
"rounded": Object { | ||
"control": Object { | ||
"type": "boolean", | ||
}, | ||
"defaultValue": true, | ||
"description": null, | ||
"name": "rounded", | ||
"table": Object { | ||
"defaultValue": Object { | ||
"summary": true, | ||
}, | ||
}, | ||
"type": Object {}, | ||
}, | ||
"text": Object { | ||
"control": Object { | ||
"type": "text", | ||
}, | ||
"defaultValue": "", | ||
"description": null, | ||
"name": "text", | ||
"table": Object { | ||
"defaultValue": Object { | ||
"summary": "", | ||
}, | ||
}, | ||
"type": Object {}, | ||
}, | ||
} | ||
`); | ||
}); | ||
}); |
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
38 changes: 38 additions & 0 deletions
38
addons/docs/src/frameworks/svelte/sample/MockButton.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,38 @@ | ||
<script> | ||
import { createEventDispatcher, afterUpdate } from 'svelte'; | ||
export let text = ''; | ||
export let rounded = true; | ||
const dispatch = createEventDispatcher(); | ||
function onClick(event) { | ||
rounded = !rounded; | ||
dispatch('click', event); | ||
} | ||
afterUpdate(() => { | ||
dispatch('afterUpdate'); | ||
}); | ||
</script> | ||
|
||
<style> | ||
.rounded { | ||
border-radius: 35px; | ||
} | ||
.button { | ||
border: 3px solid; | ||
padding: 10px 20px; | ||
background-color: white; | ||
outline: none; | ||
} | ||
</style> | ||
|
||
<svelte:options accessors={true} /> | ||
<button class="button" class:rounded on:click={onClick}> | ||
<strong>{rounded ? 'Round' : 'Square'} corners</strong> | ||
<br /> | ||
{text} | ||
<slot /> | ||
</button> |
This file was deleted.
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