-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from mParticle/feat/query-items
feat: adding QueryItem components
- Loading branch information
Showing
37 changed files
with
1,044 additions
and
131 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,50 @@ | ||
import { type Meta, type StoryObj } from '@storybook/react' | ||
import { QueryItem } from 'src/components' | ||
|
||
const meta: Meta<typeof QueryItem.Action> = { | ||
title: 'Aquarium/Data Entry/QueryItem/Action', | ||
component: QueryItem.Action, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: | ||
'This is the "Action" component of the QueryItem component group. This component is currently meant to trigger a single action, but will eventually support a list of actions via a dropdown list interface.', | ||
}, | ||
}, | ||
}, | ||
|
||
args: {}, | ||
} | ||
export default meta | ||
|
||
type Story = StoryObj<typeof QueryItem.Action> | ||
|
||
export const Primary: Story = { | ||
args: { | ||
text: 'Primary Action', | ||
type: "primary" | ||
}, | ||
} | ||
|
||
export const Secondary: Story = { | ||
args: { | ||
text: 'Secondary Action', | ||
type: "default" | ||
}, | ||
} | ||
|
||
export const Disabled: Story = { | ||
args: { | ||
text: 'Disabled Action', | ||
type: "disabled" | ||
|
||
}, | ||
} | ||
|
||
export const OnClick: Story = { | ||
args: { | ||
text: 'On Click Action', | ||
type: "primary", | ||
onClick: () => alert('You clicked the QueryItem.Action!') | ||
}, | ||
} |
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,34 @@ | ||
import { Icon, Button, IButtonProps } from 'src/components' | ||
import './query-item.css' | ||
|
||
export interface IActionProps { | ||
type?: 'disabled' | 'primary' | 'default' | ||
text?: string | ||
onClick?: () => void | ||
} | ||
|
||
export const Action = (props: IActionProps) => { | ||
let buttonClassNames: string = 'query-item query-item--action' | ||
if ((props.type ?? 'default') === 'default') buttonClassNames += ` query-item--secondary` | ||
if ((props.type ?? 'default') === 'disabled') buttonClassNames += ` query-item--disabled` | ||
|
||
const baseProps: IButtonProps = { | ||
className: buttonClassNames, | ||
type: props.type === 'disabled' ? 'default' : 'primary', | ||
disabled: props.type === 'disabled', | ||
onClick: props.onClick, | ||
} | ||
|
||
let iconColor: 'primary' | 'default' = 'primary' | ||
if (props.type == 'default') iconColor = 'default' | ||
if (props.type == 'disabled') iconColor = 'default' | ||
|
||
return ( | ||
<> | ||
<Button {...baseProps}> | ||
<Icon name="add" size="md" color={iconColor} /> | ||
<span>{props.text}</span> | ||
</Button> | ||
</> | ||
) | ||
} |
139 changes: 139 additions & 0 deletions
139
src/components/data-entry/QueryItem/Cascader.stories.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,139 @@ | ||
import { Meta, StoryObj } from '@storybook/react' | ||
import { QueryItem } from 'src/components' | ||
|
||
const meta: Meta<typeof QueryItem.ValueSelector.Cascader> = { | ||
title: 'Aquarium/Data Entry/QueryItem/ValueSelector/Cascader', | ||
component: QueryItem.ValueSelector.Cascader, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: | ||
'This is the "Action" component of the QueryItem component group. This component is currently meant to trigger a single action, but will eventually support a list of actions via a dropdown list interface.', | ||
}, | ||
}, | ||
}, | ||
|
||
args: {}, | ||
} | ||
export default meta | ||
|
||
type Story = StoryObj<typeof QueryItem.ValueSelector.Cascader> | ||
|
||
let exampleOptions = [ | ||
{ | ||
value: "United States1", | ||
label: "United States", | ||
children: [ | ||
{ | ||
value: "Michigan1", | ||
label: "Michigan", | ||
children: [ | ||
{ | ||
value: "Detroit1", | ||
label: "Detroit", | ||
}, | ||
{ | ||
value: "Lansing1", | ||
label: "Lansing", | ||
}, | ||
], | ||
}, | ||
{ | ||
value: "California1", | ||
label: "California", | ||
children: [ | ||
{ | ||
value: "San Francisco1", | ||
label: "San Francisco", | ||
}, | ||
{ | ||
value: "San Jose1", | ||
label: "San Jose", | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
value: "Canada1", | ||
label: "Canada", | ||
children: [ | ||
{ | ||
value: "Ontario1", | ||
label: "Ontario", | ||
children: [ | ||
{ | ||
value: "Toronto1", | ||
label: "Toronto", | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
export const Default: Story = { | ||
args: { | ||
placeholder: "QueryItem.ValueSelector.Cascader Default", | ||
options: exampleOptions | ||
}, | ||
} | ||
|
||
export const SimpleList: Story = { | ||
args: { | ||
placeholder: "QueryItem.ValueSelector.Cascader Simple", | ||
options: [ | ||
{ | ||
value: 'United States', | ||
label: 'United States', | ||
}, | ||
{ | ||
value: 'Canada', | ||
label: 'Canada', | ||
}, | ||
] | ||
}, | ||
} | ||
|
||
export const Error: Story = { | ||
args: { | ||
placeholder: "QueryItem.ValueSelector.Cascader Error", | ||
options: exampleOptions, | ||
errorMessage: 'test error', | ||
}, | ||
} | ||
|
||
export const Icon: Story = { | ||
args: { | ||
placeholder: "QueryItem.ValueSelector.Cascader Icon", | ||
options: exampleOptions, | ||
icon: 'event', | ||
}, | ||
} | ||
|
||
export const OnSelect: Story = { | ||
args: { | ||
placeholder: "QueryItem.ValueSelector.Cascader Error", | ||
options: exampleOptions, | ||
onChange: async (value) => console.log(value), | ||
}, | ||
} | ||
|
||
export const PreSelectedValue: Story = { | ||
args: { | ||
placeholder: "QueryItem.ValueSelector.Cascader PreSelected", | ||
options: exampleOptions, | ||
value: ["Canada1", "Ontario1", "Toronto1"], | ||
onChange: async (values, _) => {console.log(values)}, | ||
}, | ||
} | ||
|
||
export const LoadData: Story = { | ||
args: { | ||
placeholder: 'QueryItem.ValueSelector.Cascader Load', | ||
options: exampleOptions, | ||
loadData: (value: string) => { | ||
console.log(value) | ||
}, | ||
}, | ||
} |
Oops, something went wrong.