-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboard): initial scaffolding for input widget (#566)
- Loading branch information
1 parent
d8bfb2a
commit e6bbb46
Showing
11 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
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
5 changes: 5 additions & 0 deletions
5
packages/dashboard/src/components/palette/icons/input-component.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,5 @@ | ||
import React from 'react'; | ||
|
||
const InputComponent: React.FC = () => <div>input</div>; | ||
|
||
export default InputComponent; |
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
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
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
24 changes: 24 additions & 0 deletions
24
packages/dashboard/src/components/widgets/primitives/input/index.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,24 @@ | ||
import React, { useState } from 'react'; | ||
import { Button, Select, SelectProps } from '@cloudscape-design/components'; | ||
import SpaceBetween from '@cloudscape-design/components/space-between'; | ||
import { InputWidget as InputWidgetType } from '../../../../types'; | ||
|
||
export type InputWidgetProps = InputWidgetType & { readOnly: boolean }; | ||
|
||
const Input: React.FC<InputWidgetProps> = ({ readOnly, ...widget }) => { | ||
const [selectedOption, setSelectedOption] = useState<SelectProps.Option>(widget.options[0]); | ||
|
||
return ( | ||
<SpaceBetween size={'xs'} direction={'horizontal'}> | ||
<Select | ||
disabled={!readOnly} | ||
selectedOption={selectedOption} | ||
onChange={({ detail }) => setSelectedOption(detail.selectedOption)} | ||
options={widget.options} | ||
/> | ||
<Button disabled={!readOnly}>{widget.messageOverrides?.submitLabel}</Button> | ||
</SpaceBetween> | ||
); | ||
}; | ||
|
||
export default Input; |
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
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
7 changes: 7 additions & 0 deletions
7
packages/dashboard/src/store/actions/createWidget/presets/input.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,7 @@ | ||
import { InputWidget, Widget } from '../../../../types'; | ||
|
||
export const inputWidgetCreator = (componentTag: 'input', preset: Widget): InputWidget => ({ | ||
...preset, | ||
componentTag, | ||
options: [], | ||
}); |
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
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