Skip to content

Commit cca85ff

Browse files
committed
feat(ui-alerts): rework Alert
INSTUI-4782
1 parent db4f45b commit cca85ff

File tree

6 files changed

+26
-111
lines changed

6 files changed

+26
-111
lines changed

packages/ui-alerts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@instructure/shared-types": "workspace:*",
4040
"@instructure/ui-a11y-content": "workspace:*",
4141
"@instructure/ui-buttons": "workspace:*",
42-
"@instructure/ui-icons": "workspace:*",
42+
"@instructure/ui-icons-lucide": "workspace:*",
4343
"@instructure/ui-motion": "workspace:*",
4444
"@instructure/ui-react-utils": "workspace:*",
4545
"@instructure/ui-themes": "workspace:*",

packages/ui-alerts/src/Alert/index.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,16 @@ import { View } from '@instructure/ui-view'
3636
import type { ViewOwnProps } from '@instructure/ui-view'
3737
import { ScreenReaderContent } from '@instructure/ui-a11y-content'
3838
import {
39-
IconCheckMarkSolid,
40-
IconInfoBorderlessSolid,
41-
IconWarningBorderlessSolid,
42-
IconNoSolid
43-
} from '@instructure/ui-icons'
39+
InfoInstUIIcon,
40+
XCircleInstUIIcon,
41+
CircleCheckInstUIIcon,
42+
TriangleAlertInstUIIcon
43+
} from '@instructure/ui-icons-lucide'
4444
import { Transition } from '@instructure/ui-motion'
4545
import { logError as error } from '@instructure/console'
46-
import { withStyleRework as withStyle } from '@instructure/emotion'
46+
import { withStyle } from '@instructure/emotion'
4747

4848
import generateStyle from './styles'
49-
import generateComponentTheme from './theme'
5049

5150
import { allowedProps } from './props'
5251
import type { AlertProps, AlertState } from './props'
@@ -57,7 +56,7 @@ category: components
5756
---
5857
**/
5958
@withDeterministicId()
60-
@withStyle(generateStyle, generateComponentTheme)
59+
@withStyle(generateStyle)
6160
class Alert extends Component<AlertProps, AlertState> {
6261
static readonly componentId = 'Alert'
6362

@@ -88,10 +87,10 @@ class Alert extends Component<AlertProps, AlertState> {
8887
srid: string
8988

9089
variantUI = {
91-
error: IconNoSolid,
92-
info: IconInfoBorderlessSolid,
93-
success: IconCheckMarkSolid,
94-
warning: IconWarningBorderlessSolid
90+
error: XCircleInstUIIcon,
91+
info: InfoInstUIIcon,
92+
success: CircleCheckInstUIIcon,
93+
warning: TriangleAlertInstUIIcon
9594
}
9695

9796
ref: Element | null = null

packages/ui-alerts/src/Alert/styles.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
* SOFTWARE.
2323
*/
2424

25-
import type { AlertTheme } from '@instructure/shared-types'
25+
import type { NewComponentTypes, SharedTokens } from '@instructure/ui-themes'
26+
import { boxShadowObjectsToCSSString } from '@instructure/ui-themes'
2627
import type { AlertProps, AlertStyle } from './props'
2728

2829
/**
@@ -36,8 +37,9 @@ import type { AlertProps, AlertStyle } from './props'
3637
* @return {Object} The final style object, which will be used in the component
3738
*/
3839
const generateStyle = (
39-
componentTheme: AlertTheme,
40-
props: AlertProps
40+
componentTheme: NewComponentTypes['Alert'],
41+
props: AlertProps,
42+
sharedTokens: SharedTokens
4143
): AlertStyle => {
4244
const { variant, hasShadow } = props
4345

@@ -84,7 +86,11 @@ const generateStyle = (
8486
borderStyle: componentTheme.borderStyle,
8587
borderRadius: componentTheme.borderRadius,
8688
...variantStyles[variant!].alert,
87-
...(hasShadow && { boxShadow: componentTheme.boxShadow })
89+
...(hasShadow && {
90+
boxShadow: boxShadowObjectsToCSSString(
91+
sharedTokens.boxShadow.elevation4
92+
)
93+
})
8894
},
8995
icon: {
9096
color: componentTheme.iconColor,
@@ -116,7 +122,7 @@ const generateStyle = (
116122
fontFamily: componentTheme.contentFontFamily,
117123
fontWeight: componentTheme.contentFontWeight,
118124
lineHeight: componentTheme.contentLineHeight,
119-
padding: componentTheme.contentPadding
125+
padding: `${componentTheme.contentPaddingVertical} ${componentTheme.contentPaddingHorizontal}`
120126
},
121127
variantScreenReaderLabel: {
122128
position: 'absolute',

packages/ui-alerts/src/Alert/theme.ts

Lines changed: 0 additions & 90 deletions
This file was deleted.

packages/ui-alerts/tsconfig.build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
{ "path": "../ui-a11y-content/tsconfig.build.json" },
1616
{ "path": "../ui-axe-check/tsconfig.build.json" },
1717
{ "path": "../ui-buttons/tsconfig.build.json" },
18-
{ "path": "../ui-icons/tsconfig.build.json" },
18+
{ "path": "../ui-icons-lucide/tsconfig.build.json" },
1919
{ "path": "../ui-motion/tsconfig.build.json" },
2020
{ "path": "../ui-react-utils/tsconfig.build.json" },
2121
{ "path": "../ui-scripts/tsconfig.build.json" },

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)