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

[Widgets] Support theming #2667

Closed
4 tasks
tracy-french opened this issue Mar 8, 2024 · 0 comments
Closed
4 tasks

[Widgets] Support theming #2667

tracy-french opened this issue Mar 8, 2024 · 0 comments
Labels
Assigned to HM Work that is being assisted on by HM enhancement New feature or request

Comments

@tracy-french
Copy link
Contributor

To make it possible to get an iot-app-kit widget to match the styling of the consuming application, we will expose a hook-based theming API.

Below is the expected API, which should be exported from `@iot-app-kit/react-components';

import { type Theme } from '@cloudscape-design/components/theming';

/** Collection of Cloudscape design tokens supported for theming. */
type SupportedCloudscapeDesignTokens = Pick<Theme['tokens'], 'fontFamilyBase'>;
/** Collection of design tokens supported for theming. */
type Tokens = SupportedCloudscapeDesignTokens;

export interface UseThemeOptions {
  /**
   * Specifies the mode (i.e., color scheme) of the components.
   * 
   * @defaultValue `light`
   */
  mode?: 'light' | 'dark';
  /**
   * Specifies design token overrides to change the styling of components.
   */
  tokens?: Tokens;
}

/**
 * Use to set the theme of `iot-app-kit` components.
 *
 * @experimental
 * This API is experimental, is not completely functional, and is subject to 
 * breaking changes. Until stabilized, many components will not see styling 
 * changes. Do not use in production.
 */
export function useTheme({ mode = 'light', tokens }: UseThemeOptions): void {
  // implementation
}

The implementation should use Cloudscape mechanism for setting mode and theme. Please read the follow documents to understand how Cloudscape does this:

The implementation should depend on the following imports:

import { applyMode, Mode } from '@cloudscape-design/global-styles';
import { applyTheme, type Theme } from '@cloudscape-design/components/theming';

For the initial implementation, we will only expose a single token (fontFamilyBase) and the mode selection. We are only exposing a little at a time as there is additional implementation on our side to ensure all custom components are using the appropriate Cloudscape design tokens, where applicable.

The font family theme setting should be fully functional. The mode setting should use applyMode, but making sure it works effectively will be completed in separate changes.

Acceptance criteria

@tracy-french tracy-french added enhancement New feature or request Assigned to HM Work that is being assisted on by HM labels Mar 8, 2024
Chandru-HM pushed a commit to Chandru-HM/iot-app-kit that referenced this issue Mar 15, 2024
Chandru-HM pushed a commit to Chandru-HM/iot-app-kit that referenced this issue Mar 15, 2024
Chandru-HM pushed a commit to Chandru-HM/iot-app-kit that referenced this issue Mar 19, 2024
Chandru-HM pushed a commit to Chandru-HM/iot-app-kit that referenced this issue Mar 19, 2024
Chandru-HM pushed a commit to Chandru-HM/iot-app-kit that referenced this issue Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Assigned to HM Work that is being assisted on by HM enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant