Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controls: QA fixes for Object and Color controls #14392

Merged
merged 3 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/components/src/controls/Color.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ const usePresets = (
currentColor: ParsedColor,
colorSpace: ColorSpace
) => {
const [selectedColors, setSelectedColors] = useState(currentColor ? [currentColor] : []);
const [selectedColors, setSelectedColors] = useState(currentColor?.valid ? [currentColor] : []);

const presets = useMemo(() => {
const initialPresets = (presetColors || []).map((preset) => {
Expand Down Expand Up @@ -294,7 +294,10 @@ export const ColorControl: FC<ColorProps> = ({
onVisibilityChange={() => addPreset(color)}
tooltip={
<TooltipContent>
<Picker {...{ color: realValue, onChange: updateValue, onFocus, onBlur }} />
<Picker
color={realValue === 'transparent' ? '#000000' : realValue}
{...{ onChange: updateValue, onFocus, onBlur }}
/>
{presets.length > 0 && (
<Swatches>
{presets.map((preset) => (
Expand Down
4 changes: 2 additions & 2 deletions lib/components/src/controls/Object.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { ComponentProps, SyntheticEvent, useCallback, useMemo, useState }
import { styled, useTheme, Theme } from '@storybook/theming';

// @ts-ignore
import { JsonTree } from './react-editable-json-tree';
import { JsonTree, getObjectType } from './react-editable-json-tree';
import type { ControlProps, ObjectValue, ObjectConfig } from './types';
import { Form } from '../form';
import { Icons, IconsProps } from '../icon/icon';
Expand Down Expand Up @@ -260,7 +260,7 @@ export const ObjectControl: React.FC<ObjectProps> = ({ name, value, onChange })

return (
<Wrapper>
{hasData && (
{hasData && ['Object', 'Array'].includes(getObjectType(data)) && (
<RawButton onClick={() => setShowRaw((v) => !v)}>
<Icons icon={showRaw ? 'eyeclose' : 'eye'} />
<span>RAW</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ JsonTree.defaultProps = {
};

export { JsonTree };
export { getObjectType };
export { ADD_DELTA_TYPE };
export { REMOVE_DELTA_TYPE };
export { UPDATE_DELTA_TYPE };
Expand Down