-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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 #19451 from storybookjs/tom/sb-557-typescript-2
Add Preact/Webpack templates and update renderer/preset (2)
- Loading branch information
Showing
18 changed files
with
174 additions
and
55 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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
/** @jsx h */ | ||
import { h } from 'preact'; | ||
import PropTypes from 'prop-types'; | ||
import './button.css'; | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
/** @jsx h */ | ||
import { h } from 'preact'; | ||
import { Header } from './Header'; | ||
|
||
export default { | ||
|
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
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,3 +1,3 @@ | ||
export { renderToDOM } from './render'; | ||
export { renderToDOM, render } from './render'; | ||
|
||
export const parameters = { framework: 'preact' as const }; |
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,14 @@ | ||
/* eslint-disable react/react-in-jsx-scope */ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import PropTypes from 'prop-types'; | ||
|
||
export const Button = ({ onClick, children }) => ( | ||
<button type="button" onClick={onClick}> | ||
{children} | ||
</button> | ||
); | ||
|
||
Button.propTypes = { | ||
onClick: PropTypes.func.isRequired, | ||
children: PropTypes.node.isRequired, | ||
}; |
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 @@ | ||
/* eslint-disable react/react-in-jsx-scope */ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import PropTypes from 'prop-types'; | ||
import { useState } from 'preact/hooks'; | ||
|
||
export const Form = ({ onSuccess }) => { | ||
const [value, setValue] = useState(''); | ||
const [complete, setComplete] = useState(false); | ||
|
||
function onSubmit(event) { | ||
event.preventDefault(); | ||
onSuccess(value); | ||
|
||
setTimeout(() => setComplete(true), 500); | ||
setTimeout(() => setComplete(false), 1500); | ||
} | ||
|
||
return ( | ||
<form id="interaction-test-form" onSubmit={onSubmit}> | ||
<label> | ||
Enter Value | ||
<input | ||
type="text" | ||
data-testid="value" | ||
value={value} | ||
required | ||
onChange={(event) => setValue(event.target.value)} | ||
/> | ||
</label> | ||
<button type="submit">Submit</button> | ||
{complete && <p>Completed!!</p>} | ||
</form> | ||
); | ||
}; | ||
|
||
Form.propTypes = { | ||
onSuccess: PropTypes.func.isRequired, | ||
}; |
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,10 @@ | ||
/* eslint-disable react/react-in-jsx-scope */ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import PropTypes from 'prop-types'; | ||
|
||
// eslint-disable-next-line react/no-danger | ||
export const Html = ({ content }) => <div dangerouslySetInnerHTML={{ __html: content }} />; | ||
|
||
Html.propTypes = { | ||
content: PropTypes.string.isRequired, | ||
}; |
Oops, something went wrong.