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

chore: remove filled icon style setting #36300

Merged
merged 3 commits into from
Sep 13, 2024
Merged
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
Expand Up @@ -67,15 +67,5 @@ describe(
anvilSnapshot.matchSnapshotForDeployMode(`AppThemingCorner${corner}`);
});
});

it("6. Icon Style", () => {
["Filled", "Outlined"].forEach((iconStyle) => {
anvilSnapshot.setIconStyle(iconStyle);

anvilSnapshot.matchSnapshotForCanvasMode(`AppThemingIcon${iconStyle}`);
anvilSnapshot.matchSnapshotForPreviewMode(`AppThemingIcon${iconStyle}`);
anvilSnapshot.matchSnapshotForDeployMode(`AppThemingIcon${iconStyle}`);
});
});
},
);
9 changes: 0 additions & 9 deletions app/client/cypress/support/Pages/Anvil/AnvilSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export class AnvilSnapshot {
densityOptions: "[data-testid=t--anvil-theme-settings-density] > div",
sizingOptions: "[data-testid=t--anvil-theme-settings-sizing] > div",
cornersOptions: "[data-testid=t--anvil-theme-settings-corners] > div",
iconStyleOptions: "[data-testid=t--anvil-theme-settings-icon-style] > div",
};

/**
Expand Down Expand Up @@ -163,14 +162,6 @@ export class AnvilSnapshot {
});
};

public setIconStyle = (iconStyle: string) => {
this.updateThemeOption(() => {
cy.get(this.locators.iconStyleOptions)
.contains(iconStyle)
.click({ force: true });
});
};

public updateThemeOption = (callback: () => void) => {
this.appSettings.OpenAppSettings();
this.appSettings.GoToThemeSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from "./";

import type { ColorMode } from "../../color";
import type { TokenSource, IconStyle } from "../../token";
import type { TokenSource } from "../../token";

const tokensAccessor = new TokensAccessor({
...(defaultTokens as TokenSource),
Expand All @@ -22,14 +22,12 @@ export interface UseThemeProps {
borderRadius?: string;
userDensity?: number;
userSizing?: number;
iconStyle?: IconStyle;
}

export function useTheme(props: UseThemeProps = {}) {
const {
borderRadius,
colorMode = "light",
iconStyle = "outlined",
seedColor,
userDensity = 1,
userSizing = 1,
Expand Down Expand Up @@ -88,9 +86,6 @@ export function useTheme(props: UseThemeProps = {}) {
tokensAccessor.updateOuterSpacing(outerSpacing);
tokensAccessor.updateInnerSpacing(innerSpacing);

// Icon style
tokensAccessor.updateIconStyle(iconStyle);

// Icon size
if (iconSize != null) {
tokensAccessor.updateIconSize(iconSize);
Expand All @@ -110,7 +105,6 @@ export function useTheme(props: UseThemeProps = {}) {
...tokensAccessor.getSizing(),
...tokensAccessor.getOuterSpacing(),
...tokensAccessor.getInnerSpacing(),
iconStyle: tokensAccessor.getIconStyle(),
...tokensAccessor.getIconSize(),
...tokensAccessor.getStrokeWidth(),
};
Expand All @@ -122,7 +116,6 @@ export function useTheme(props: UseThemeProps = {}) {
sizing,
outerSpacing,
innerSpacing,
iconStyle,
iconSize,
strokeWidth,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import type { ReactNode } from "react";
import type { CSSProperties } from "react";

import type { ColorMode } from "../../color";
import type { Typography, ThemeToken, IconStyle } from "../../token";
import type { Typography, ThemeToken } from "../../token";

export type Theme = ThemeToken & {
typography?: Typography;
colorMode?: ColorMode;
iconStyle?: IconStyle;
};

export interface ThemeProviderProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type {
TokenSource,
TokenType,
Typography,
IconStyle,
} from "./types";

export class TokensAccessor {
Expand All @@ -23,7 +22,6 @@ export class TokensAccessor {
private innerSpacing?: TokenObj;
private sizing?: TokenObj;
private zIndex?: TokenObj;
private iconStyle?: IconStyle;
private strokeWidth?: TokenObj;
private iconSize?: TokenObj;

Expand All @@ -33,7 +31,6 @@ export class TokensAccessor {
boxShadow,
colorMode,
iconSize,
iconStyle,
innerSpacing,
opacity,
outerSpacing,
Expand All @@ -54,7 +51,6 @@ export class TokensAccessor {
this.innerSpacing = innerSpacing;
this.typography = typography;
this.zIndex = zIndex;
this.iconStyle = iconStyle;
this.strokeWidth = strokeWidth;
this.iconSize = iconSize;
}
Expand Down Expand Up @@ -112,10 +108,6 @@ export class TokensAccessor {
this.sizing = sizing;
};

updateIconStyle = (iconStyle: IconStyle) => {
this.iconStyle = iconStyle;
};

updateStrokeWidth = (strokeWidth: TokenObj) => {
this.strokeWidth = strokeWidth;
};
Expand All @@ -139,7 +131,6 @@ export class TokensAccessor {
...this.getStrokeWidth(),
...this.getIconSize(),
colorMode: this.getColorMode(),
iconStyle: this.getIconStyle(),
};
};

Expand Down Expand Up @@ -224,10 +215,6 @@ export class TokensAccessor {
return this.colorMode;
};

getIconStyle = () => {
return this.iconStyle;
};

getStrokeWidth = () => {
if (this.strokeWidth == null) return {} as ThemeToken;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export interface TokenSource {
sizing?: TokenObj;
outerSpacing?: TokenObj;
innerSpacing?: TokenObj;
iconStyle?: IconStyle;
strokeWidth?: TokenObj;
iconSize?: TokenObj;
}
Expand Down Expand Up @@ -106,8 +105,6 @@ export type Typography = {
[key in keyof typeof TYPOGRAPHY_VARIANTS]: TypographyVariantMetric;
};

export type IconStyle = "outlined" | "filled";

export const APP_MAX_WIDTH = {
Unlimited: "UNLIMITED",
Large: "LARGE",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
import type { Component, Ref } from "react";
import React, { Suspense, forwardRef, lazy, useMemo } from "react";
import { useThemeContext } from "@appsmith/wds-theming";

import { ICONS } from "./icons";
import styles from "./styles.module.css";
import type { IconProps } from "./types";
import { FallbackIcon } from "./FallbackIcon";

const _Icon = (props: IconProps, ref: Ref<Component>) => {
const { color, filled: filledProp, name, size = "medium", ...rest } = props;
const theme = useThemeContext();
const filled = theme.iconStyle === "filled" || filledProp;
const { color, name, size = "medium", ...rest } = props;

const Icon = useMemo(() => {
const pascalName = ICONS[name];

return lazy(async () =>
import("@tabler/icons-react").then((module) => {
if (Boolean(filled)) {
const filledVariant = `${pascalName}Filled`;

if (filledVariant in module) {
return {
default: module[filledVariant] as React.ComponentType,
};
}
}

if (pascalName in module) {
return {
default: module[pascalName] as React.ComponentType,
Expand All @@ -36,7 +23,7 @@ const _Icon = (props: IconProps, ref: Ref<Component>) => {
return { default: FallbackIcon };
}),
);
}, [name, filled]);
}, [name]);

return (
<Suspense
Expand Down
Loading
Loading