feat: add Number field preview in settings (#2397)

Closes #2327
This commit is contained in:
Thaïs 2023-11-09 08:30:37 +01:00 committed by GitHub
parent 1f5492b4a7
commit 28779f0fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 8 deletions

View File

@ -6,6 +6,7 @@ const StyledSettingsPageContainer = styled.div<{ width?: number }>`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: ${({ theme }) => theme.spacing(8)}; gap: ${({ theme }) => theme.spacing(8)};
overflow: auto;
padding: ${({ theme }) => theme.spacing(8)}; padding: ${({ theme }) => theme.spacing(8)};
width: ${({ width }) => (width ? width + 'px' : objectSettingsWidth)}; width: ${({ width }) => (width ? width + 'px' : objectSettingsWidth)};
`; `;

View File

@ -64,7 +64,7 @@ export const SettingsObjectFieldTypeSelectSection = ({
}), }),
)} )}
/> />
{fieldType === 'TEXT' && ( {['NUMBER', 'TEXT'].includes(fieldType) && (
<StyledSettingsObjectFieldTypeCard <StyledSettingsObjectFieldTypeCard
preview={ preview={
<SettingsObjectFieldPreview <SettingsObjectFieldPreview

View File

@ -12,15 +12,31 @@ const meta: Meta<typeof SettingsObjectFieldPreview> = {
fieldIconKey: 'IconNotes', fieldIconKey: 'IconNotes',
fieldLabel: 'Description', fieldLabel: 'Description',
fieldType: 'TEXT', fieldType: 'TEXT',
objectIconKey: 'IconUser', isObjectCustom: false,
objectLabelPlural: 'People', objectIconKey: 'IconBuildingSkyscraper',
objectNamePlural: 'people', objectLabelPlural: 'Companies',
objectNamePlural: 'companies',
}, },
}; };
export default meta; export default meta;
type Story = StoryObj<typeof SettingsObjectFieldPreview>; type Story = StoryObj<typeof SettingsObjectFieldPreview>;
export const StandardObject: Story = { args: { isObjectCustom: false } }; export const Text: Story = {};
export const CustomObject: Story = { args: { isObjectCustom: true } }; export const Number: Story = {
args: {
fieldIconKey: 'IconUsers',
fieldLabel: 'Employees',
fieldType: 'NUMBER',
},
};
export const CustomObject: Story = {
args: {
isObjectCustom: true,
objectIconKey: 'IconApps',
objectLabelPlural: 'Workspaces',
objectNamePlural: 'workspaces',
},
};

View File

@ -9,7 +9,16 @@ const meta: Meta<typeof SettingsObjectFieldTypeSelectSection> = {
title: 'Modules/Settings/DataModel/SettingsObjectFieldTypeSelectSection', title: 'Modules/Settings/DataModel/SettingsObjectFieldTypeSelectSection',
component: SettingsObjectFieldTypeSelectSection, component: SettingsObjectFieldTypeSelectSection,
decorators: [ComponentDecorator], decorators: [ComponentDecorator],
args: { fieldType: 'NUMBER' }, args: {
fieldType: 'NUMBER',
fieldIconKey: 'IconUsers',
fieldLabel: 'Employees',
fieldName: 'employees',
isObjectCustom: false,
objectIconKey: 'IconUser',
objectLabelPlural: 'People',
objectNamePlural: 'people',
},
}; };
export default meta; export default meta;
@ -17,6 +26,10 @@ type Story = StoryObj<typeof SettingsObjectFieldTypeSelectSection>;
export const Default: Story = {}; export const Default: Story = {};
export const Disabled: Story = {
args: { disabled: true },
};
export const WithOpenSelect: Story = { export const WithOpenSelect: Story = {
play: async ({ canvasElement }) => { play: async ({ canvasElement }) => {
const canvas = within(canvasElement); const canvas = within(canvasElement);

View File

@ -13,7 +13,7 @@ export const dataTypes: Record<
MetadataFieldDataType, MetadataFieldDataType,
{ label: string; Icon: IconComponent; defaultValue?: unknown } { label: string; Icon: IconComponent; defaultValue?: unknown }
> = { > = {
NUMBER: { label: 'Number', Icon: IconNumbers }, NUMBER: { label: 'Number', Icon: IconNumbers, defaultValue: 2000 },
TEXT: { TEXT: {
label: 'Text', label: 'Text',
Icon: IconTextSize, Icon: IconTextSize,