Skip to content

Commit

Permalink
[support-storybook7] #3 수정 시도 (activeUserAgent > $activeUserAgent)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sotaneum committed Jul 23, 2023
1 parent eaf8cc6 commit ab969b4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/Tool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import { TOOL_ID } from './constants';

export const Tool = () => {
const [args = {}] = useArgs();
const { activeUserAgent } = args;
const { $activeUserAgent } = args;

const change = useUserAgent(getInlineFrame());

useEffect(() => {
if (activeUserAgent) {
change(activeUserAgent);
if ($activeUserAgent) {
change($activeUserAgent);
}
}, [change, activeUserAgent]);
}, [change, $activeUserAgent]);

return (
<WithTooltip
Expand All @@ -35,7 +35,7 @@ export const Tool = () => {
rev=""
title="Change UserAgent"
nonce=""
active={!!activeUserAgent}
active={!!$activeUserAgent}
content=""
autoFocus={false}
>
Expand Down
4 changes: 2 additions & 2 deletions src/components/PanelContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import UserAgent from './UserAgent';

export default function PanelContent() {
const [args = {}] = useArgs();
const { activeUserAgent } = args;
const { $activeUserAgent } = args;

return (
<>
<UserAgent name="iframe" userAgent={activeUserAgent} />
<UserAgent name="iframe" userAgent={$activeUserAgent} />
<UserAgent name="Window" userAgent={window?.navigator?.userAgent} />
</>
);
Expand Down
10 changes: 5 additions & 5 deletions src/components/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import { Link, TooltipProps, UserAgentParameter } from '../types';
export default function Tooltip({ onChange }: TooltipProps) {
const [args = {}, updateArgs] = useArgs();
const userAgentList = getUserAgentList();
const { activeUserAgent } = args;
const { $activeUserAgent } = args;

const handleClick = (userAgent: string) => {
const newUserAgent = activeUserAgent !== userAgent ? userAgent : '';
const newUserAgent = $activeUserAgent !== userAgent ? userAgent : '';
onChange(newUserAgent);
updateArgs({ activeUserAgent: newUserAgent });
updateArgs({ $activeUserAgent: newUserAgent });
};

const links: Link[] = useMemo(
Expand All @@ -24,11 +24,11 @@ export default function Tooltip({ onChange }: TooltipProps) {
return {
id: `${idx}_${name}`,
title: name,
active: userAgent === activeUserAgent,
active: userAgent === $activeUserAgent,
onClick: () => handleClick(userAgent),
};
}),
[userAgentList, activeUserAgent]
[userAgentList, $activeUserAgent]
);

return <TooltipLinkList links={links} />;
Expand Down
2 changes: 1 addition & 1 deletion src/preset/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ addons.register(ADDON_ID, () => {
type: types.TOOL,
title: TOOL_TITLE,
paramKey: PARAM_KEY,
match: ({ viewMode }) => !!viewMode?.match(/^(story|docs)$/),
match: ({ viewMode }) => viewMode === 'story',
render: Tool,
});

Expand Down
2 changes: 1 addition & 1 deletion src/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default makeDecorator({
name: 'userAgentRender',
parameterName: 'userAgent',
wrapper: (storyFn, context) => {
const nowUserAgent: string = context.globals.activeUserAgent ?? '';
const nowUserAgent: string = context.globals.$activeUserAgent ?? '';

const [key, setKey] = useState(Date.now());
const [userAgent, setUserAgent] = useState(nowUserAgent);
Expand Down

0 comments on commit ab969b4

Please sign in to comment.