Skip to content

Commit a03fa07

Browse files
authored
feat: wrap spectrum View, Text and Heading to accept custom colors (#1903)
- Exposes our extra semantic colors to these components - Created colorUtils in theme, containing theme variables - Move spectrumUtils to spectrum/utils (was originally going to put it here) - Added eslint config to allow using UNSAFE_styles/UNSAFE_classname Tested with: ```html <Text color="red">css red</Text> <Text color="red-1000">theme red-1000</Text> <Text color="accent">accent</Text> <Text color="positive">positive</Text> <Text color="negative">negative</Text> <Text color="info">info</Text> <Text color="notice">notice</Text> <Text color="bg">bg</Text> <Text color="color-mix(in srgb, red, blue)">purple</Text> ```
1 parent f8a12f7 commit a03fa07

26 files changed

Lines changed: 502 additions & 25 deletions

packages/code-studio/src/styleguide/Pickers.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import React, { useCallback, useState } from 'react';
2-
import { Picker, PickerItemKey, Section } from '@deephaven/components';
2+
import {
3+
Flex,
4+
Picker,
5+
PickerItemKey,
6+
Section,
7+
Text,
8+
} from '@deephaven/components';
39
import { vsPerson } from '@deephaven/icons';
4-
import { Flex, Icon, Item, Text } from '@adobe/react-spectrum';
10+
import { Icon, Item } from '@adobe/react-spectrum';
511
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
612
import { sampleSectionIdAndClasses } from './utils';
713

packages/code-studio/src/styleguide/RandomAreaPlotAnimation.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* eslint-disable react/jsx-props-no-spreading */
22
import React from 'react';
3-
import { View } from '@adobe/react-spectrum';
4-
import { RandomAreaPlotAnimation as Animation } from '@deephaven/components';
3+
import {
4+
View,
5+
RandomAreaPlotAnimation as Animation,
6+
} from '@deephaven/components';
57
import { sampleSectionIdAndClasses } from './utils';
68

79
export function RandomAreaPlotAnimation(): JSX.Element {

packages/code-studio/src/styleguide/SpectrumComparison.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import {
1414
Radio,
1515
RadioGroup,
1616
SpectrumButtonProps,
17-
Text,
1817
TextField,
19-
View,
2018
} from '@adobe/react-spectrum';
2119
import {
2220
Button as BootstrapButtonOld,
@@ -25,6 +23,8 @@ import {
2523
RadioGroup as RadioGroupOld,
2624
RadioItem,
2725
Select,
26+
View,
27+
Text,
2828
} from '@deephaven/components';
2929
import { EMPTY_FUNCTION } from '@deephaven/utils';
3030
import { vsPlay } from '@deephaven/icons';

packages/code-studio/src/styleguide/SpectrumComponents.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
Column,
1212
ComboBox,
1313
Form,
14-
Heading,
1514
Grid,
1615
Icon,
1716
IllustratedMessage,
@@ -24,10 +23,8 @@ import {
2423
TableBody,
2524
TableHeader,
2625
TableView,
27-
Text,
2826
TextField,
2927
ToggleButton,
30-
View,
3128
Well,
3229
DialogTrigger,
3330
Dialog,
@@ -39,6 +36,7 @@ import {
3936
} from '@adobe/react-spectrum';
4037
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4138
import { dhTruck, vsEmptyWindow } from '@deephaven/icons';
39+
import { Heading, View, Text } from '@deephaven/components';
4240
import { SPECTRUM_COMPONENT_SAMPLES_ID } from './constants';
4341
import { sampleSectionIdAndClassesSpectrum } from './utils';
4442

packages/code-studio/src/styleguide/StyleGuide.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
/* eslint-disable react/jsx-props-no-spreading */
22
import React from 'react';
3-
import { Flex } from '@adobe/react-spectrum';
4-
import { ContextMenuRoot, ThemePicker, useTheme } from '@deephaven/components';
3+
4+
import {
5+
ContextMenuRoot,
6+
ThemePicker,
7+
useTheme,
8+
Flex,
9+
} from '@deephaven/components';
510

611
import Buttons from './Buttons';
712
import Charts from './Charts';

packages/components/src/TextWithTooltip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useMemo } from 'react';
2-
import { Text } from '@adobe/react-spectrum';
2+
import { Text } from './spectrum';
33
import stylesCommon from './SpectrumComponent.module.scss';
44
import { PopperOptions, Tooltip } from './popper';
55

packages/components/src/dialogs/ActionButtonDialogTrigger.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { ReactElement } from 'react';
2-
import { ActionButton, DialogTrigger, Icon, Text } from '@adobe/react-spectrum';
2+
import { ActionButton, DialogTrigger, Icon } from '@adobe/react-spectrum';
33
import type { SpectrumDialogClose } from '@react-types/dialog';
44
import type { StyleProps } from '@react-types/shared';
55
import type { IconDefinition } from '@fortawesome/fontawesome-common-types';
66
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
7+
import { Text } from '../spectrum';
78
import { Tooltip } from '../popper';
89

910
export interface ActionButtonDialogTriggerProps extends StyleProps {

packages/components/src/dialogs/ConfirmationDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import {
77
Dialog,
88
Divider,
99
Form,
10-
Heading,
1110
} from '@adobe/react-spectrum';
1211
import type { SpectrumLabelableProps } from '@react-types/shared';
1312
import { useFormWithDetachedSubmitButton } from '@deephaven/react-hooks';
13+
import { Heading } from '../spectrum';
1414
import styles from '../SpectrumComponent.module.scss';
1515

1616
export interface ConfirmationDialogProps {

packages/components/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export * from './SelectValueList';
4949
export * from './shortcuts';
5050
export { default as SocketedButton } from './SocketedButton';
5151
export * from './spectrum';
52-
export * from './SpectrumUtils';
52+
export * from './spectrum/utils';
5353
export * from './TableViewEmptyState';
5454
export * from './TextWithTooltip';
5555
export * from './theme';
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
import { Heading } from './Heading';
4+
5+
describe('Heading', () => {
6+
it('mounts and unmounts', () => {
7+
render(<Heading>{null}</Heading>);
8+
});
9+
10+
it('renders without color', () => {
11+
const { getByTestId } = render(<Heading data-testid="Heading" />);
12+
const HeadingElement = getByTestId('Heading');
13+
expect(HeadingElement).toBeInTheDocument();
14+
});
15+
16+
it('renders with color', () => {
17+
const color = 'red';
18+
const { getByTestId } = render(
19+
<Heading data-testid="Heading" color={color} />
20+
);
21+
const HeadingElement = getByTestId('Heading');
22+
expect(HeadingElement).toBeInTheDocument();
23+
expect(HeadingElement).toHaveStyle(`color: ${color}`);
24+
});
25+
});

0 commit comments

Comments
 (0)