-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(ui/v2): Update icons and search bars on schema tab, glossary search, domain search #12740
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import { ButtonVariantValues } from '@components/components/Button/types'; | ||
import { MATERIAL_UI_ICONS, PHOSPHOR_ICONS } from '@components/components/Icon/constants'; | ||
import { SizeValues } from '@components/theme/config'; | ||
import React from 'react'; | ||
|
||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
@@ -33,7 +36,7 @@ const meta = { | |
}, | ||
variant: { | ||
description: 'The variant of the Button.', | ||
options: ['filled', 'outline', 'text'], | ||
options: Object.values(ButtonVariantValues), | ||
table: { | ||
defaultValue: { summary: buttonDefaults.variant }, | ||
}, | ||
|
@@ -43,7 +46,7 @@ const meta = { | |
}, | ||
color: { | ||
description: 'The color of the Button.', | ||
options: ['violet', 'green', 'red', 'blue', 'gray'], | ||
options: ['violet', 'green', 'red', 'gray'], | ||
table: { | ||
defaultValue: { summary: buttonDefaults.color }, | ||
}, | ||
|
@@ -53,31 +56,22 @@ const meta = { | |
}, | ||
size: { | ||
description: 'The size of the Button.', | ||
options: ['sm', 'md', 'lg', 'xl'], | ||
options: Object.values(SizeValues), | ||
table: { | ||
defaultValue: { summary: buttonDefaults.size }, | ||
}, | ||
control: { | ||
type: 'select', | ||
}, | ||
}, | ||
iconSize: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Attached to |
||
description: 'The optional size of the Icon.', | ||
options: ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl'], | ||
table: { | ||
defaultValue: { | ||
summary: 'undefined', | ||
detail: 'The size of the Button will be used as the size of the Icon', | ||
}, | ||
}, | ||
control: { | ||
type: 'select', | ||
}, | ||
}, | ||
icon: { | ||
description: 'The icon to display in the Button.', | ||
type: 'string', | ||
options: AVAILABLE_ICONS, | ||
mapping: Object.fromEntries([ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maps |
||
...MATERIAL_UI_ICONS.map((icon) => [icon, { icon, source: 'material', size: '2xl' }]), | ||
...PHOSPHOR_ICONS.map((icon) => [icon, { icon, source: 'phosphor', size: '2xl' }]), | ||
]), | ||
table: { | ||
defaultValue: { summary: 'undefined' }, | ||
}, | ||
|
@@ -143,7 +137,7 @@ const meta = { | |
|
||
// Define defaults | ||
args: { | ||
children: 'Button Content', | ||
children: 'Button', | ||
variant: buttonDefaults.variant, | ||
color: buttonDefaults.color, | ||
size: buttonDefaults.size, | ||
|
@@ -167,7 +161,7 @@ type Story = StoryObj<typeof meta>; | |
// Pass props to this so that it can be customized via the UI props panel | ||
export const sandbox: Story = { | ||
tags: ['dev'], | ||
render: (props) => <Button {...props}>Button</Button>, | ||
render: (props) => <Button {...props} />, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Properly set |
||
}; | ||
|
||
export const states = () => ( | ||
|
@@ -191,26 +185,27 @@ export const colors = () => ( | |
|
||
export const sizes = () => ( | ||
<GridList> | ||
<Button size="sm">Small Button</Button> | ||
<Button size="md">Regular Button</Button> | ||
<Button size="lg">Large Button</Button> | ||
<Button size="xl">XLarge Button</Button> | ||
<Button size="xs">XSmall</Button> | ||
<Button size="sm">Small</Button> | ||
<Button size="md">Regular</Button> | ||
<Button size="lg">Large</Button> | ||
<Button size="xl">XLarge</Button> | ||
</GridList> | ||
); | ||
|
||
export const withIcon = () => ( | ||
<GridList> | ||
<Button icon="Add">Icon Left</Button> | ||
<Button icon="Add" iconPosition="right"> | ||
<Button icon={{ icon: 'Add', source: 'material' }}>Icon Left</Button> | ||
<Button icon={{ icon: 'Add', source: 'material' }} iconPosition="right"> | ||
Icon Right | ||
</Button> | ||
</GridList> | ||
); | ||
|
||
export const circleShape = () => ( | ||
<GridList> | ||
<Button icon="Add" size="sm" isCircle /> | ||
<Button icon="Add" isCircle /> | ||
<Button icon="Add" size="lg" isCircle /> | ||
<Button icon={{ icon: 'Add', source: 'material' }} size="sm" isCircle /> | ||
<Button icon={{ icon: 'Add', source: 'material' }} isCircle /> | ||
<Button icon={{ icon: 'Add', source: 'material' }} size="lg" isCircle /> | ||
</GridList> | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,7 @@ const getButtonColorStyles = (variant: ButtonVariant, color: ColorOptions): Colo | |
|
||
bgColor: colors.transparent, | ||
borderColor: colors.transparent, | ||
hoverBgColor: colors.transparent, | ||
hoverBgColor: colors.gray[1500], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Request from Anna: adds light gray on hover of "text" buttons |
||
activeBgColor: colors.transparent, | ||
disabledBgColor: colors.transparent, | ||
disabledBorderColor: colors.transparent, | ||
|
@@ -151,26 +151,7 @@ const getButtonFontStyles = (size: SizeOptions) => { | |
lineHeight: typography.lineHeights.none, | ||
}; | ||
|
||
const sizeStyles = { | ||
sm: { | ||
...baseFontStyles, | ||
fontSize: getFontSize(size), // 12px | ||
}, | ||
md: { | ||
...baseFontStyles, | ||
fontSize: getFontSize(size), // 14px | ||
}, | ||
lg: { | ||
...baseFontStyles, | ||
fontSize: getFontSize(size), // 16px | ||
}, | ||
xl: { | ||
...baseFontStyles, | ||
fontSize: getFontSize(size), // 18px | ||
}, | ||
}; | ||
|
||
return sizeStyles[size]; | ||
return { ...baseFontStyles, fontSize: getFontSize(size) }; | ||
}; | ||
|
||
// Generate radii styles for button | ||
|
@@ -180,13 +161,14 @@ const getButtonRadiiStyles = (isCircle: boolean) => { | |
}; | ||
|
||
// Generate padding styles for button | ||
const getButtonPadding = (size: SizeOptions, variant: ButtonVariant, isCircle: boolean) => { | ||
const getButtonPadding = (size: SizeOptions, hasChildren: boolean, isCircle: boolean) => { | ||
if (isCircle) return { padding: spacing.xsm }; | ||
if (!hasChildren) return { padding: spacing.xsm }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Custom padding for buttons that are just icons |
||
|
||
const paddingStyles = { | ||
xs: { | ||
vertical: 0, | ||
horizontal: 0, | ||
vertical: 6, | ||
horizontal: 6, | ||
Comment on lines
+170
to
+171
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not actually used but this seems more appropriate |
||
}, | ||
sm: { | ||
vertical: 8, | ||
|
@@ -208,7 +190,7 @@ const getButtonPadding = (size: SizeOptions, variant: ButtonVariant, isCircle: b | |
|
||
const selectedStyle = paddingStyles[size]; | ||
const verticalPadding = selectedStyle.vertical; | ||
const horizontalPadding = variant === 'text' ? 0 : selectedStyle.horizontal; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding padding back to text buttons after talking to Anna |
||
const horizontalPadding = selectedStyle.horizontal; | ||
return { padding: `${verticalPadding}px ${horizontalPadding}px` }; | ||
}; | ||
|
||
|
@@ -221,16 +203,16 @@ const getButtonActiveStyles = (colorStyles: ColorStyles) => ({ | |
}); | ||
|
||
// Generate loading styles for button | ||
const getButtonLoadingStyles = () => ({ | ||
const getButtonLoadingStyles = (): CSSObject => ({ | ||
pointerEvents: 'none', | ||
opacity: 0.75, | ||
}); | ||
|
||
/* | ||
* Main function to generate styles for button | ||
*/ | ||
export const getButtonStyle = (props: ButtonStyleProps) => { | ||
const { variant, color, size, isCircle, isActive, isLoading, isDisabled } = props; | ||
export const getButtonStyle = (props: ButtonStyleProps): CSSObject => { | ||
const { variant, color, size, isCircle, isActive, isLoading, isDisabled, hasChildren } = props; | ||
|
||
// Get map of colors | ||
const colorStyles = getButtonColorStyles(variant, color); | ||
|
@@ -239,10 +221,10 @@ export const getButtonStyle = (props: ButtonStyleProps) => { | |
const variantStyles = getButtonVariantStyles(variant, colorStyles); | ||
const fontStyles = getButtonFontStyles(size); | ||
const radiiStyles = getButtonRadiiStyles(isCircle); | ||
const paddingStyles = getButtonPadding(size, variant, isCircle); | ||
const paddingStyles = getButtonPadding(size, hasChildren, isCircle); | ||
|
||
// Base of all generated styles | ||
let styles = { | ||
let styles: CSSObject = { | ||
...variantStyles, | ||
...fontStyles, | ||
...radiiStyles, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import { SearchOutlined } from '@ant-design/icons'; | ||
import { Icon } from '@src/alchemy-components'; | ||
import { InputProps } from 'antd'; | ||
import React from 'react'; | ||
import { StyledSearchBar } from './components'; | ||
import { SearchBarProps } from './types'; | ||
|
||
export const searchBarDefaults: SearchBarProps = { | ||
placeholder: 'Search...', | ||
value: '', | ||
width: '272px', | ||
width: '100%', | ||
allowClear: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default to 100% instead, I do make the corresponding change in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. anywhere else this was used that was banking on that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just that and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore me, I just added that too. Only place it was used is StructuredProperties |
||
}; | ||
|
||
|
@@ -16,15 +17,17 @@ export const SearchBar = ({ | |
width = searchBarDefaults.width, | ||
allowClear = searchBarDefaults.allowClear, | ||
onChange, | ||
}: SearchBarProps) => { | ||
...props | ||
}: SearchBarProps & Omit<InputProps, 'onChange'>) => { | ||
return ( | ||
<StyledSearchBar | ||
placeholder={placeholder} | ||
onChange={(e) => onChange?.(e.target.value)} | ||
value={value} | ||
prefix={<SearchOutlined />} | ||
prefix={<Icon icon="MagnifyingGlass" source="phosphor" />} | ||
allowClear={allowClear} | ||
$width={width} | ||
{...props} | ||
/> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request from Anna (no blue buttons)