-
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.
feat(queryitem): adding QueryItem.Qualifier component
- Loading branch information
Showing
6 changed files
with
71 additions
and
10 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/components/data-entry/QueryItem/QueryItem.Qualifier.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,28 @@ | ||
import { QueryItemQualifier } from './QueryItem.Qualifier' | ||
import { type Meta, type StoryObj } from '@storybook/react' | ||
|
||
type Story = StoryObj<typeof QueryItemQualifier> | ||
|
||
// default | ||
const meta: Meta<typeof QueryItemQualifier> = { | ||
title: 'Aquarium/Data Entry/QueryItem.Qualifier', | ||
component: QueryItemQualifier, | ||
args: {}, | ||
} | ||
export default meta | ||
|
||
// stories | ||
export const Empty: Story = {} | ||
|
||
export const Simple: Story = { | ||
args: { | ||
options: [ | ||
{ value: '0', label: 'is equal to' }, | ||
{ value: '1', label: 'is not equal to' }, | ||
{ value: '2', label: 'is greater than to' }, | ||
{ value: '3', label: 'is greater or equal to' }, | ||
{ value: '4', label: 'is less than' }, | ||
{ value: '5', label: 'is less or equal to' }, | ||
], | ||
}, | ||
} |
24 changes: 24 additions & 0 deletions
24
src/components/data-entry/QueryItem/QueryItem.Qualifier.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 './query-item.css' | ||
import { CheckIcon } from 'src/components/icons' | ||
import type { DefaultOptionType } from 'antd/es/select' | ||
import { type ISelectProps, Select } from '../Select/Select' | ||
|
||
export type IQueryItemQualifierOption = DefaultOptionType | ||
|
||
export interface IQueryItemQualifierProps { | ||
options: IQueryItemQualifierOption[] | ||
} | ||
|
||
export const QueryItemQualifier = (props: IQueryItemQualifierProps) => { | ||
const selectProps: ISelectProps = { | ||
defaultValue: props.options?.length ? props.options[0].value : undefined, | ||
options: props.options, | ||
menuItemSelectedIcon: node => | ||
node.isSelected ? <CheckIcon className="query-item-qualifier__item-selected-icon" /> : null, | ||
placement: 'bottomLeft', | ||
popupMatchSelectWidth: false, | ||
suffixIcon: null, | ||
variant: 'borderless', | ||
} | ||
return <Select className="query-item-qualifier__select" {...selectProps}></Select> | ||
} |
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 { QueryItemQualifier } from './QueryItem.Qualifier' | ||
|
||
export const QueryItem = { | ||
Qualifier: QueryItemQualifier, | ||
} |
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 @@ | ||
.query-item-qualifier__item-selected-icon { | ||
margin-left: 5px; | ||
} | ||
|
||
.query-item-qualifier__select .ant-select-selection-item { | ||
border-bottom: 4px solid var(--mp-brand-primary-8); | ||
} |
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