-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added line style customization per property
- Loading branch information
1 parent
a46da1d
commit abe942f
Showing
4 changed files
with
132 additions
and
24 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
packages/dashboard/src/customization/propertiesSections/components/lineStyleDropdown.tsx
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,35 @@ | ||
import React from 'react'; | ||
import type { FC } from 'react'; | ||
import { FormField, Select } from '@cloudscape-design/components'; | ||
|
||
const defaultLineStyleOption = { label: 'Solid', value: 'solid' }; | ||
const lineStyleOptions = [ | ||
defaultLineStyleOption, | ||
{ label: 'Dashed', value: 'dashed' }, | ||
{ label: 'Dotted', value: 'dotted' }, | ||
] as const; | ||
|
||
type LineStyleDropdownProps = { | ||
disabled?: boolean; | ||
lineStyle?: string; | ||
updatelineStyle: (lineStyle: string) => void; | ||
}; | ||
|
||
export const LineStyleDropdown: FC<LineStyleDropdownProps> = ({ disabled = false, lineStyle, updatelineStyle }) => { | ||
return ( | ||
<FormField label='Style'> | ||
<Select | ||
disabled={disabled} | ||
selectedOption={ | ||
// Find the line style option that matches the currently selected line style | ||
lineStyleOptions.find(({ value }) => value === lineStyle) ?? null | ||
} | ||
onChange={({ detail }) => | ||
// Update the line style with the selected option value | ||
updatelineStyle(detail.selectedOption.value ?? defaultLineStyleOption.value) | ||
} | ||
options={lineStyleOptions} // List of line style options | ||
/> | ||
</FormField> | ||
); | ||
}; |
27 changes: 27 additions & 0 deletions
27
packages/dashboard/src/customization/propertiesSections/components/lineThicknessDropdown.tsx
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,27 @@ | ||
import React from 'react'; | ||
import type { FC } from 'react'; | ||
|
||
import { FormField, Select } from '@cloudscape-design/components'; | ||
|
||
const defaultLineThicknessOption = { label: 'Normal', value: 'normal' }; | ||
const lineThicknessOptions = [ | ||
{ label: 'Thin', value: 'thin' }, | ||
defaultLineThicknessOption, | ||
{ label: 'Thick', value: 'thick' }, | ||
] as const; | ||
|
||
type LineThicknessDropdownProps = { | ||
disabled?: boolean; | ||
}; | ||
|
||
export const LineThicknessDropdown: FC<LineThicknessDropdownProps> = ({ disabled = false }) => { | ||
return ( | ||
<FormField label='Thickness'> | ||
<Select | ||
disabled={disabled} | ||
selectedOption={lineThicknessOptions.find(({ value }) => value === 'normal') ?? null} | ||
options={lineThicknessOptions} | ||
/> | ||
</FormField> | ||
); | ||
}; |
29 changes: 11 additions & 18 deletions
29
...ard/src/customization/propertiesSections/lineAndScatterStyleSettings/lineStyleSection.tsx
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,31 +1,24 @@ | ||
import ExpandableSection from '@cloudscape-design/components/expandable-section'; | ||
import FormField from '@cloudscape-design/components/form-field'; | ||
import Select from '@cloudscape-design/components/select'; | ||
import type { FC } from 'react'; | ||
import React from 'react'; | ||
import type { FC } from 'react'; | ||
|
||
import ExpandableSection from '@cloudscape-design/components/expandable-section'; | ||
|
||
const defaultLineStyleOption = { label: 'Solid', value: 'solid' }; | ||
const lineStyleOptions = [ | ||
defaultLineStyleOption, | ||
{ label: 'Dashed', value: 'dashed' }, | ||
{ label: 'Dotted', value: 'dotted' }, | ||
] as const; | ||
import { LineStyleDropdown } from '../components/lineStyleDropdown'; | ||
import { LineThicknessDropdown } from '../components/lineThicknessDropdown'; | ||
import { SpaceBetween } from '@cloudscape-design/components'; | ||
|
||
type LineStyleSectionOptions = { | ||
lineStyle: string | undefined; | ||
lineStyle?: string; | ||
updatelineStyle: (lineStyle: string) => void; | ||
}; | ||
|
||
export const LineStyleSection: FC<LineStyleSectionOptions> = ({ lineStyle, updatelineStyle }) => { | ||
return ( | ||
<ExpandableSection headerText='Line style' defaultExpanded> | ||
<FormField label='Style'> | ||
<Select | ||
selectedOption={lineStyleOptions.find(({ value }) => value === lineStyle) ?? null} | ||
onChange={({ detail }) => updatelineStyle(detail.selectedOption.value ?? defaultLineStyleOption.value)} | ||
options={lineStyleOptions} | ||
/> | ||
</FormField> | ||
<SpaceBetween size='m'> | ||
<LineStyleDropdown lineStyle={lineStyle} updatelineStyle={updatelineStyle} /> | ||
<LineThicknessDropdown /> {/* TODO */} | ||
</SpaceBetween> | ||
</ExpandableSection> | ||
); | ||
}; |
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