mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-31 05:03:21 +08:00
Merge branch 'next' into tech/change-event-source-to-refId
This commit is contained in:
commit
f862d08643
@ -4,6 +4,11 @@ import Button from '../components/TsButton';
|
||||
export default {
|
||||
title: 'Addons/Controls',
|
||||
component: Button,
|
||||
argTypes: {
|
||||
children: { control: 'text' },
|
||||
type: { control: 'text' },
|
||||
somethingElse: { control: 'object' },
|
||||
},
|
||||
};
|
||||
|
||||
const Story = (args) => <Button {...args} />;
|
||||
@ -11,12 +16,14 @@ const Story = (args) => <Button {...args} />;
|
||||
export const Basic = Story.bind({});
|
||||
Basic.args = {
|
||||
children: 'basic',
|
||||
somethingElse: { a: 2 },
|
||||
};
|
||||
|
||||
export const Action = Story.bind({});
|
||||
Action.args = {
|
||||
children: 'hmmm',
|
||||
type: 'action',
|
||||
somethingElse: { a: 4 },
|
||||
};
|
||||
|
||||
export const CustomControls = Story.bind({});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { FC, ChangeEvent, useState, useCallback } from 'react';
|
||||
import React, { FC, ChangeEvent, useState, useCallback, useEffect } from 'react';
|
||||
import { styled } from '@storybook/theming';
|
||||
|
||||
import deepEqual from 'fast-deep-equal';
|
||||
@ -36,6 +36,11 @@ export const ObjectControl: FC<ObjectProps> = ({
|
||||
const [valid, setValid] = useState(true);
|
||||
const [text, setText] = useState(format(value));
|
||||
|
||||
useEffect(() => {
|
||||
const newText = format(value);
|
||||
if (text !== newText) setText(newText);
|
||||
}, [value]);
|
||||
|
||||
const handleChange = useCallback(
|
||||
(e: ChangeEvent<HTMLTextAreaElement>) => {
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user