Skip to content

Commit

Permalink
feat: add Action QueryItem
Browse files Browse the repository at this point in the history
  • Loading branch information
ZoeAstra committed Apr 9, 2024
1 parent 1fe60d8 commit f76ea2b
Show file tree
Hide file tree
Showing 13 changed files with 733 additions and 410 deletions.
77 changes: 76 additions & 1 deletion design/GlobalToken.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
"value": "#f8f6fb"
},
"colorBgLayout": {
"value": "#fff"
"value": "#ffffff"
},
"colorBgSpotlight": {
"value": "#2c2d2b"
Expand Down Expand Up @@ -344,6 +344,81 @@
"mpColorBorderDisabled": {
"value": "#dcdcd8"
},
"mpQueryItem_borderWidth": {
"value": "0 0 1px 0"
},
"mpQueryItem_borderColor": {
"value": "#c3aeff"
},
"mpQueryItem_borderColor_active": {
"value": "#3600d1"
},
"mpQueryItem_borderColor_disabled": {
"value": "#dcdcd8"
},
"mpQueryItem_borderColor_error": {
"value": "#f5222d"
},
"mpQueryItem_bgColor": {
"value": "#ffffff"
},
"mpQueryItem_bgColor_hover": {
"value": "#f8f6fb"
},
"mpQueryItem_bgColor_active": {
"value": "#ebe8f8"
},
"mpQueryItem_bgColor_disabled": {
"value": "#faf9f8"
},
"mpQueryItem_borderWidth_active": {
"value": "0 0 2px 0"
},
"mpQueryItem_shadow_focus": {
"value": "0 0 0 2px rgba(54, 0, 209, 0.1)"
},
"mpQueryItem_color_disabled": {
"value": "#505249"
},
"mpQueryItem|valueSelector_fontWeight": {
"value": "600"
},
"mpQueryItem|valueSelector_color": {
"value": "#20007a"
},
"mpQueryItem_padding": {
"value": "4px"
},
"mpQueryItem_gap": {
"value": "4px"
},
"mpQueryItem_height": {
"value": "32px"
},
"mpQueryItem_borderRadius": {
"value": "2px"
},
"mpQueryItem|action|primary_color": {
"value": "#3600d1"
},
"mpQueryItem|action|secondary_color": {
"value": "#505249"
},
"mpQueryItem|action_fontWeight": {
"value": "400"
},
"mpQueryItem_shadow_active": {
"value": "0 0 0 2px rgba(54, 0, 209, 0.1)"
},
"mpQueryItem_shadow": {
"value": "none"
},
"mpQueryItem_borderColor_focus": {
"value": "#3600d1"
},
"mpQueryItem_borderColor_hover": {
"value": "#3600d1"
},
"blue1": {
"value": "#e6f4ff"
},
Expand Down
27 changes: 26 additions & 1 deletion design/LightTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const LightTheme: IMpThemeConfig = {
colorFillSecondary: '#ebe8f8',
colorFillTertiary: '#faf9f8',
colorFillQuaternary: '#f8f6fb',
colorBgLayout: '#fff',
colorBgLayout: '#ffffff',
colorBgSpotlight: '#2c2d2b',
colorBorder: '#c3aeff',
colorBorderSecondary: '#eceae9',
Expand Down Expand Up @@ -82,6 +82,31 @@ export const LightTheme: IMpThemeConfig = {
'mpBrandSecondary.9': '#212020',
'mpBrandSecondary.10': '#0f0e0e',
mpColorBorderDisabled: '#dcdcd8',
mpQueryItem_borderWidth: '0 0 1px 0',
mpQueryItem_borderColor: '#c3aeff',
mpQueryItem_borderColor_active: '#3600d1',
mpQueryItem_borderColor_disabled: '#dcdcd8',
mpQueryItem_borderColor_error: '#f5222d',
mpQueryItem_bgColor: '#ffffff',
mpQueryItem_bgColor_hover: '#f8f6fb',
mpQueryItem_bgColor_active: '#ebe8f8',
mpQueryItem_bgColor_disabled: '#faf9f8',
mpQueryItem_borderWidth_active: '0 0 2px 0',
mpQueryItem_shadow_focus: '0 0 0 2px rgba(54, 0, 209, 0.1)',
mpQueryItem_color_disabled: '#505249',
'mpQueryItem|valueSelector_fontWeight': '600',
'mpQueryItem|valueSelector_color': '#20007a',
mpQueryItem_padding: 4,
mpQueryItem_gap: 4,
mpQueryItem_height: 32,
mpQueryItem_borderRadius: 2,
'mpQueryItem|action|primary_color': '#3600d1',
'mpQueryItem|action|secondary_color': '#505249',
'mpQueryItem|action_fontWeight': '400',
mpQueryItem_shadow_active: '0 0 0 2px rgba(54, 0, 209, 0.1)',
mpQueryItem_shadow: 'none',
mpQueryItem_borderColor_focus: '#3600d1',
mpQueryItem_borderColor_hover: '#3600d1',
},
components: {
Steps: {
Expand Down
25 changes: 25 additions & 0 deletions design/MpThemeConfig.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,31 @@ export type IMpThemeConfig = ThemeConfig & {
['mpBrandSecondary.9']: string
['mpBrandSecondary.10']: string
mpColorBorderDisabled: string
mpQueryItem_borderWidth: '0 0 1px 0'
mpQueryItem_borderColor: '#c3aeff'
mpQueryItem_borderColor_active: '#3600d1'
mpQueryItem_borderColor_disabled: '#dcdcd8'
mpQueryItem_borderColor_error: '#f5222d'
mpQueryItem_bgColor: '#ffffff'
mpQueryItem_bgColor_hover: '#f8f6fb'
mpQueryItem_bgColor_active: '#ebe8f8'
mpQueryItem_bgColor_disabled: '#faf9f8'
mpQueryItem_borderWidth_active: '0 0 2px 0'
mpQueryItem_shadow_focus: '0 0 0 2px rgba(54, 0, 209, 0.1)'
mpQueryItem_color_disabled: '#505249'
'mpQueryItem|valueSelector_fontWeight': '600'
'mpQueryItem|valueSelector_color': '#20007a'
mpQueryItem_padding: 4
mpQueryItem_gap: 4
mpQueryItem_height: 32
mpQueryItem_borderRadius: 2
'mpQueryItem|action|primary_color': '#3600d1'
'mpQueryItem|action|secondary_color': '#505249'
'mpQueryItem|action_fontWeight': '400'
mpQueryItem_shadow_active: '0 0 0 2px rgba(54, 0, 209, 0.1)'
mpQueryItem_shadow: 'none'
mpQueryItem_borderColor_focus: '#3600d1'
mpQueryItem_borderColor_hover: '#3600d1'
}
components: {
Select: { mpColorBorderDisabled: string }
Expand Down
44 changes: 44 additions & 0 deletions src/components/data-entry/QueryItem/Action.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Meta, 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',
isPrimary: true,
isDisabled: false,
},
}

export const Secondary: Story = {
args: {
text: 'Secondary Action',
isPrimary: false,
isDisabled: false,
},
}

export const Disabled: Story = {
args: {
text: 'Disabled Action',
isPrimary: true,
isDisabled: true,
},
}
24 changes: 24 additions & 0 deletions src/components/data-entry/QueryItem/Action.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { AddIcon, Button } from 'src/components'
import './query-item.css'

export interface IActionProps {
isPrimary?: boolean
isDisabled?: boolean
text?: string
}

function Action(props: IActionProps) {
const buttonClassNames: string = props.isPrimary
? 'query-item-action'
: 'query-item-action query-item-action--secondary'
return (
<>
<Button className={buttonClassNames} type={props.isPrimary ? 'primary' : 'default'} disabled={props.isDisabled}>
<AddIcon className={'query-item-action__icon'} />
<span>{props.text && props.text}</span>
</Button>
</>
)
}

export default Action
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { QueryItemQualifier } from './QueryItem.Qualifier'
import { QueryItem } from './QueryItem'
import { type Meta, type StoryObj } from '@storybook/react'

type Story = StoryObj<typeof QueryItemQualifier>
type Story = StoryObj<typeof QueryItem.Qualifier>

// default
const meta: Meta<typeof QueryItemQualifier> = {
title: 'Aquarium/Data Entry/QueryItem.Qualifier',
component: QueryItemQualifier,
const meta: Meta<typeof QueryItem.Qualifier> = {
title: 'Aquarium/Data Entry/QueryItem/Qualifier',
component: QueryItem.Qualifier,
args: {},
}
export default meta
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import './query-item.css'
import { CheckIcon } from 'src/components/icons'
import type { DefaultOptionType } from 'antd/es/select'
import { type ISelectProps, Select } from '../Select/Select'
import { type ISelectProps, Select } from 'src/components'

export type IQueryItemQualifierOption = DefaultOptionType

export interface IQueryItemQualifierProps {
options: IQueryItemQualifierOption[]
}

export const QueryItemQualifier = (props: IQueryItemQualifierProps) => {
export const Qualifier = (props: IQueryItemQualifierProps) => {
const selectProps: ISelectProps = {
defaultValue: props.options?.length ? props.options[0].value : undefined,
options: props.options,
Expand Down
22 changes: 22 additions & 0 deletions src/components/data-entry/QueryItem/QueryItem.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Meta, StoryObj } from '@storybook/react'
import { QueryItem } from 'src/components'

const meta: Meta<typeof QueryItem> = {
title: 'Aquarium/Data Entry/QueryItem',
component: QueryItem,
parameters: {
docs: {
description: {
component:
'DO NOT USE THIS OR YOU WILL BE FIRED! This is a parent component of this component group, and is not supposed to be used on its own.',
},
},
},

args: {},
}
export default meta

type Story = StoryObj<typeof QueryItem>

export const DontUseThisOrYouWillBeFired: Story = {}
10 changes: 7 additions & 3 deletions src/components/data-entry/QueryItem/QueryItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { QueryItemQualifier } from './QueryItem.Qualifier'
import React from 'react'
import Action from './Action'
import { Qualifier } from './Qualifier'

export const QueryItem = {
Qualifier: QueryItemQualifier,
export const QueryItem = () => {
return <>DON'T USE THIS OR YOU WILL BE FIRED!</>
}
QueryItem.Action = Action
QueryItem.Qualifier = Qualifier
65 changes: 63 additions & 2 deletions src/components/data-entry/QueryItem/query-item.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,68 @@
@import "src/styles/_variables.css";
/*border-bottom: 3px solid var(--color-primary);*/
.query-item-action {
border-width: var(--mp-query-item-border-width);
border-color: var(--mp-query-item-border-color) !important;
border-radius: var(--mp-query-item-border-radius);
background: var(--mp-query-item-bg-color) !important;
padding: var(--mp-query-item-padding) !important;
gap: var(--mp-query-item-gap);
color: var(--mp-query-item-action-primary-color) !important;
height: var(--mp-query-item-height) !important;
display: flex;
justify-content: center;
align-items: center;
box-shadow: none;


&:hover {
border-color: var(--mp-query-item-border-color-active) !important;
background: var(--mp-query-item-bg-color-hover) !important;
}

&:focus {
border-color: var(--mp-query-item-border-color-active) !important;
box-shadow: var(--mp-query-item-shadow-focus);
background: var(--mp-query-item-bg-color) !important;
}

&:active {
border-color: var(--mp-query-item-border-color-active) !important;
border-width: var(--mp-query-item-border-width-active);
background: var(--mp-query-item-bg-color-active) !important;
box-shadow: var(--mp-query-item-shadow-active);
}

&.query-item-action--secondary {
color: var(--mp-query-item-action-secondary-color) !important;

&:hover {
background: var(--mp-query-item-bg-color-hover) !important;
}

&:active {
border-width: var(--mp-query-item-border-width-active);
background: var(--mp-query-item-bg-color-active) !important;
}
}

&[disabled] {
color: var(--mp-query-item-color-disabled) !important;
border-color: var(--mp-query-item-border-color-disabled) !important;
}
}

/*This is temporary until the new icon component is available where sizes can be controlled without CSS*/
.query-item-action__icon {
height: 16px;
width: 16px;
}


.query-item-qualifier__item-selected-icon {
margin-left: 5px;
margin-left: 5px;
}

.query-item-qualifier__select .ant-select-selection-item {
border-bottom: 4px solid var(--mp-brand-primary-8);
border-bottom: 4px solid var(--mp-brand-primary-8);
}
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export { Upload, type IUploadProps } from './data-entry/Upload/Upload'
export { AutoComplete, type IAutoCompleteProps } from './data-entry/AutoComplete/AutoComplete'
export { TimePicker, type ITimePickerProps } from './data-entry/TimePicker/TimePicker'
export { Transfer, type ITransferProps } from './data-entry/Transfer/Transfer'
export { QueryItem } from './data-entry/QueryItem/QueryItem'
export { Collapse, type ICollapseProps } from './data-display/Collapse/Collapse'
export { Timeline, type ITimelineProps } from './data-display/Timeline/Timeline'
export { Calendar, type ICalendarProps } from './data-display/Calendar/Calendar'
Expand Down
Loading

0 comments on commit f76ea2b

Please sign in to comment.