diff --git a/packages/ui-badge/src/Badge/README.md b/packages/ui-badge/src/Badge/README.md index 00f0da42c3..01618bcbf1 100644 --- a/packages/ui-badge/src/Badge/README.md +++ b/packages/ui-badge/src/Badge/README.md @@ -26,7 +26,7 @@ type: example }} > } screenReaderLabel="Edits" withBorder={false} withBackground={false} @@ -39,7 +39,7 @@ type: example }} > } screenReaderLabel="Edits" withBorder={false} withBackground={false} @@ -137,7 +137,7 @@ type: example --- const EditButton = () => ( } screenReaderLabel="Edit page" withBorder={false} withBackground={false} diff --git a/packages/ui-badge/src/Badge/index.tsx b/packages/ui-badge/src/Badge/index.tsx index 2ca6f6ce8e..3d8f3017a8 100644 --- a/packages/ui-badge/src/Badge/index.tsx +++ b/packages/ui-badge/src/Badge/index.tsx @@ -30,10 +30,9 @@ import { withDeterministicId } from '@instructure/ui-react-utils' -import { withStyleRework as withStyle } from '@instructure/emotion' +import { withStyle } from '@instructure/emotion' import generateStyle from './styles' -import generateComponentTheme from './theme' import { allowedProps } from './props' import type { BadgeProps } from './props' @@ -44,7 +43,7 @@ category: components --- **/ @withDeterministicId() -@withStyle(generateStyle, generateComponentTheme) +@withStyle(generateStyle) class Badge extends Component { static readonly componentId = 'Badge' diff --git a/packages/ui-badge/src/Badge/styles.ts b/packages/ui-badge/src/Badge/styles.ts index 0982dba1e4..6804e35250 100644 --- a/packages/ui-badge/src/Badge/styles.ts +++ b/packages/ui-badge/src/Badge/styles.ts @@ -24,7 +24,7 @@ import { keyframes } from '@instructure/emotion' -import type { BadgeTheme } from '@instructure/shared-types' +import type { NewComponentTypes } from '@instructure/ui-themes' import type { BadgeProps, BadgeStyle } from './props' // keyframes have to be outside of 'generateStyle', @@ -46,7 +46,7 @@ const pulseAnimation = keyframes` * @return {Object} The final style object, which will be used in the component */ const generateStyle = ( - componentTheme: BadgeTheme, + componentTheme: NewComponentTypes['Badge'], props: BadgeProps ): BadgeStyle => { const { type, variant, placement = '', standalone, pulse } = props diff --git a/packages/ui-badge/src/Badge/theme.ts b/packages/ui-badge/src/Badge/theme.ts deleted file mode 100644 index c6aaa6a061..0000000000 --- a/packages/ui-badge/src/Badge/theme.ts +++ /dev/null @@ -1,74 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 - present Instructure, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import type { Theme, ThemeSpecificStyle } from '@instructure/ui-themes' -import { BadgeTheme } from '@instructure/shared-types' - -/** - * Generates the theme object for the component from the theme and provided additional information - * @param {Object} theme The actual theme object. - * @return {Object} The final theme object with the overrides and component variables - */ -const generateComponentTheme = (theme: Theme): BadgeTheme => { - const { - borders, - colors, - spacing, - typography, - stacking, - key: themeName - } = theme - - const themeSpecificStyle: ThemeSpecificStyle = { - canvas: { - colorPrimary: theme['ic-brand-primary'] - } - } - - const componentVariables: BadgeTheme = { - fontFamily: typography?.fontFamily, - fontWeight: typography?.fontWeightNormal, - color: colors?.contrasts?.white1010, - fontSize: typography?.fontSizeXSmall, - colorDanger: colors?.contrasts?.red4570, - colorSuccess: colors?.contrasts?.green4570, - colorPrimary: colors?.contrasts?.blue4570, - colorInverse: colors?.contrasts?.grey4570, - size: '1.25rem', - countOffset: '0.5rem', - notificationOffset: '0.125rem', - notificationZIndex: stacking?.above, - sizeNotification: spacing?.small, - borderRadius: '999rem', - padding: spacing?.xxSmall, - pulseBorderThickness: borders?.widthMedium - } - - return { - ...componentVariables, - ...themeSpecificStyle[themeName] - } -} - -export default generateComponentTheme