Skip to content
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

Color tokens test page updates #3023

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import * as React from 'react';
import type { ViewStyle, ColorValue } from 'react-native';
import type { ColorValue } from 'react-native';
import { View, StyleSheet, Platform } from 'react-native';

import { Text, ToggleButton } from '@fluentui/react-native';
import { createAliasTokens } from '@fluentui-react-native/default-theme';
import type { SvgIconProps } from '@fluentui-react-native/icon';
import { globalTokens } from '@fluentui-react-native/theme-tokens';
import type { Theme } from '@fluentui-react-native/theme-types';
import { useTheme } from '@fluentui-react-native/theme-types';
import { themedStyleSheet } from '@fluentui-react-native/themed-stylesheet';
import { getCurrentAppearance } from '@fluentui-react-native/theming-utils';
import { createOfficeAliasTokens } from '@fluentui-react-native/win32-theme';
import type { SvgProps } from 'react-native-svg';
import Svg, { G, Path } from 'react-native-svg';

Expand Down Expand Up @@ -56,11 +53,6 @@ const styles = StyleSheet.create({
colorDescriptionNamePadding: { paddingRight: 5 },
});

const getSwatchColorStyle = (colorName: string, colorValue: ColorValue): ViewStyle => {
styles[colorName] = styles[colorName] || { backgroundColor: colorValue };
return styles[colorName];
};

type ColorTokenProps = { colorValue: ColorValue; colorName: string };
const ColorToken: React.FunctionComponent<ColorTokenProps> = (p: ColorTokenProps) => {
if (p.colorValue === undefined) {
Expand All @@ -71,7 +63,7 @@ const ColorToken: React.FunctionComponent<ColorTokenProps> = (p: ColorTokenProps
return (
<View style={styles.swatchItem}>
<View
style={[getSwatchColorStyle(p.colorName, p.colorValue), themedStyles.swatch]}
style={[{ backgroundColor: p.colorValue }, themedStyles.swatch]}
/* For Android E2E testing purposes, testProps must be passed in after accessibilityLabel. */
{...testProps(COLORTOKENS_TEST_COMPONENT)}
/>
Expand All @@ -92,17 +84,7 @@ const getSwatch = (item) => {

const AliasColorTokensSwatchList: React.FunctionComponent = () => {
const theme = useTheme();

const isOfficeTheme =
theme.name === 'White' ||
theme.name === 'Colorful' ||
theme.name === 'DarkGray' ||
theme.name === 'Black' ||
theme.name === 'HighContrast';

const aliasColorTokens = isOfficeTheme
? createOfficeAliasTokens(theme.name)
: createAliasTokens(getCurrentAppearance(theme.host.appearance, 'light'));
const aliasColorTokens = theme.colors;

const aggregator = React.useCallback(
(colorName: string) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Color tokens test updates",
"packageName": "@fluentui-react-native/tester",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Loading