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

New Admin UI - Colors and Theming #4474

Draft
wants to merge 41 commits into
base: feat/new-admin-ui
Choose a base branch
from

Conversation

adrians5j
Copy link
Member

@adrians5j adrians5j commented Jan 7, 2025

Changes

For starters, this PR brings in the primitive tokens for colors (check theme out here).

With these tokens now in theme.scss, we now reference them in alias tokens. Previously, alias tokens directly had color codes assigned to them.

All of this ultimately enables easier Admin theme customization, which is done via the new AdminConfig.Theme React component. Here are two examples.

// extensions/adminTheme/src/index.tsx
import React from "react";
import { AdminConfig } from "@webiny/app-serverless-cms";

const { Theme } = AdminConfig;

export const Extension = () => {
    return (
        <AdminConfig>
            <Theme>
                <Theme.Color palette={"primary"} color={"purple"} />
            </Theme>
        </AdminConfig>
    );
};
// extensions/adminTheme/src/index.tsx
import React from "react";
import { AdminConfig, Plugin, IsNotRootTenant, IsRootTenant } from "@webiny/app-serverless-cms";

const { Theme } = AdminConfig;

export const Extension = () => {
    return (
        <Plugin>
            <IsRootTenant>
                <AdminConfig>
                    <Theme>
                        <Theme.Color palette={"primary"} color={"purple"} />
                    </Theme>
                </AdminConfig>
            </IsRootTenant>
            <IsNotRootTenant>
                <AdminConfig>
                    <Theme>
                        <Theme.Color palette={"primary"} color={"blue"} />
                    </Theme>
                </AdminConfig>
            </IsNotRootTenant>
        </Plugin>
    );
};

There are a couple of things to note though.

First, not that the AdminConfig.Theme component is actually NOT a React properties component.
packages/app-wcp/src/WcpProvider.tsx

Second, while I was testing the above code examples, I noticed glitches. ✍🏻

Additional Changes

1. Minor Cleanups

1.1. packages/app-admin-cognito/src/components/StyledComponents.ts

Saw links in the sign in screen still orange, because there was some custom styling done with the --mdc-theme-... CSS variables.

1.2. packages/app-admin-rmwc/src/modules/Navigation/Styled.ts

Removed custom styling since it was no longer needed. There will be probably more to remove but for now didn't go too far.

1.3. packages/app-admin/src/styles/material-theme-assignments.scss

Accidentally saw this file and decided to remove CSS that I was sure we won't be needing any more (old components). More cleaning up in this file will be needed.

2. Updated app-serverless-cms Exports

This package now exports not only the new AdminConfig, but also the tenancy-related components. Better to have everything in one place (easier for users).

3. Removed Component Mount Tracking

Component mount tracking was removed in packages/app-tenant-manager/src/index.tsx. This basically resolved an issue where, in a MT setup, in a specific case you would not see the tenant selector in top-right corner of the screen. Thanks goes to Pavel for this one.

How Has This Been Tested?

Manually.

Documentation

Add theming doc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants