Skip to content

Commit

Permalink
feat(queryitem): adding QueryItem.Qualifier component
Browse files Browse the repository at this point in the history
  • Loading branch information
brewdente committed Apr 9, 2024
1 parent 4648888 commit 1fe60d8
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 10 deletions.
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 src/components/data-entry/QueryItem/QueryItem.Qualifier.tsx
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>
}
5 changes: 5 additions & 0 deletions src/components/data-entry/QueryItem/QueryItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { QueryItemQualifier } from './QueryItem.Qualifier'

export const QueryItem = {
Qualifier: QueryItemQualifier,
}
7 changes: 7 additions & 0 deletions src/components/data-entry/QueryItem/query-item.css
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);
}
5 changes: 0 additions & 5 deletions src/styles/style.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* Do not edit directly
* Generated on Thu, 21 Mar 2024 19:23:25 GMT
*/

export const Blue = '#1677ff'
export const Purple = '#722ED1'
export const Cyan = '#13C2C2'
Expand Down
12 changes: 7 additions & 5 deletions src/utils/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ describe('Testing utils', () => {

it('it should return "Windows" when the user agent includes "Win"', () => {
// arrange
global.navigator = {
const navigatorOverride: Partial<Navigator> = {
userAgent: 'Windows',
} as Navigator
}
global.navigator = { ...global.navigator, ...navigatorOverride }

// act
const actualOS = getOS()
Expand All @@ -42,9 +43,10 @@ describe('Testing utils', () => {

it('it should return "Macintosh" when the user agent includes "Mac"', () => {
// arrange
global.navigator = {
const navigatorOverride: Partial<Navigator> = {
userAgent: 'Macintosh',
} as Navigator
}
global.navigator = { ...global.navigator, ...navigatorOverride }

// act
const actualOS = getOS()
Expand All @@ -53,4 +55,4 @@ describe('Testing utils', () => {
expect(actualOS).toBe('Macintosh')
})
})
})
})

0 comments on commit 1fe60d8

Please sign in to comment.