{
data-cid="ColorContrast"
>
-
- {label}
-
+ {labelLevel ? (
+
+ {label}
+
+ ) : (
+
+ {label}
+
+ )}
{contrast}:1
{this.renderPreview()}
diff --git a/packages/ui-color-picker/src/ColorContrast/props.ts b/packages/ui-color-picker/src/ColorContrast/props.ts
index b5b0163420..c8abd09b60 100644
--- a/packages/ui-color-picker/src/ColorContrast/props.ts
+++ b/packages/ui-color-picker/src/ColorContrast/props.ts
@@ -22,12 +22,15 @@
* SOFTWARE.
*/
+import React from 'react'
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
import type {
OtherHTMLAttributes,
ColorContrastTheme
} from '@instructure/shared-types'
+type HeadingLevel = U
+
type ColorContrastOwnProps = {
/**
* Provides a reference to the component's underlying html element.
@@ -53,6 +56,10 @@ type ColorContrastOwnProps = {
* Label of the component
*/
label: string
+ /**
+ * The heading level for the label. If provided, the label will be rendered as a `` instead of ``.
+ */
+ labelLevel?: HeadingLevel<'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'>
/**
* Text of the second check (Suggested english text: Large text)
*/
@@ -154,6 +161,7 @@ const allowedProps: AllowedPropKeys = [
'graphicsTextLabel',
'withoutColorPreview',
'label',
+ 'labelLevel',
'largeTextLabel',
'normalTextLabel',
'secondColor',
diff --git a/packages/ui-color-picker/src/ColorContrast/styles.ts b/packages/ui-color-picker/src/ColorContrast/styles.ts
index a9db350f07..d2dac4bd10 100644
--- a/packages/ui-color-picker/src/ColorContrast/styles.ts
+++ b/packages/ui-color-picker/src/ColorContrast/styles.ts
@@ -23,6 +23,7 @@
*/
import type { ColorContrastTheme } from '@instructure/shared-types'
+import type { ColorContrastProps } from './props'
/**
* ---
* private: true
@@ -33,7 +34,10 @@ import type { ColorContrastTheme } from '@instructure/shared-types'
* @param {Object} state the state of the component, the style is applied to
* @return {Object} The final style object, which will be used in the component
*/
-const generateStyle = (componentTheme: ColorContrastTheme) => {
+const generateStyle = (
+ componentTheme: ColorContrastTheme,
+ props: ColorContrastProps
+) => {
const statusDescriptionStyle = (pass: boolean) => ({
label: pass
? 'colorContrast__successDescription'
@@ -94,7 +98,8 @@ const generateStyle = (componentTheme: ColorContrastTheme) => {
},
label: {
label: 'colorContrast__label',
- marginBottom: componentTheme.labelBottomMargin
+ marginBottom: componentTheme.labelBottomMargin,
+ ...(props.labelLevel && { fontWeight: 'bold' })
}
}
}
diff --git a/packages/ui-color-picker/tsconfig.build.json b/packages/ui-color-picker/tsconfig.build.json
index 81bd533281..299f914361 100644
--- a/packages/ui-color-picker/tsconfig.build.json
+++ b/packages/ui-color-picker/tsconfig.build.json
@@ -18,6 +18,7 @@
{ "path": "../ui-buttons/tsconfig.build.json" },
{ "path": "../ui-color-utils/tsconfig.build.json" },
{ "path": "../ui-form-field/tsconfig.build.json" },
+ { "path": "../ui-heading/tsconfig.build.json" },
{ "path": "../ui-icons/tsconfig.build.json" },
{ "path": "../ui-pill/tsconfig.build.json" },
{ "path": "../ui-popover/tsconfig.build.json" },
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 231714ddeb..f0d7da0c94 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1579,6 +1579,9 @@ importers:
'@instructure/ui-form-field':
specifier: workspace:*
version: link:../ui-form-field
+ '@instructure/ui-heading':
+ specifier: workspace:*
+ version: link:../ui-heading
'@instructure/ui-icons':
specifier: workspace:*
version: link:../ui-icons