Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
chore: offboard styling ffs
Browse files Browse the repository at this point in the history
  • Loading branch information
ymchandra committed Apr 11, 2024
1 parent 71bebda commit 6c07b55
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 39 deletions.
4 changes: 2 additions & 2 deletions src/__tests__/styling-utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe("Styling options", () => {
},
};
layout.components = [component];
const style = getAxisLabelStyle(theme, layout, flags);
const style = getAxisLabelStyle(theme, layout);
expect(style.fontFamily).toEqual("aLabelFont, sans-serif");
expect(style.fontSize).toEqual("2000");
expect(style.fill).toEqual("green");
Expand All @@ -78,7 +78,7 @@ describe("Styling options", () => {
},
};
layout.components = [component];
const style = getValueLabelStyle(theme, layout, flags);
const style = getValueLabelStyle(theme, layout);
expect(style.fontFamily).toEqual("vLabelFont, sans-serif");
expect(style.fontSize).toEqual(3000);
expect(style.fill).toEqual("blue");
Expand Down
6 changes: 1 addition & 5 deletions src/ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ export default function ext(env) {
}
return [];
};
const stylingPanelEnabled = flags.isEnabled("SENSECLIENT_IM_2022_STYLINGPANEL_MEKKOCHART");
const bkgOptionsEnabled = flags.isEnabled("SENSECLIENT_IM_2022_MEKKO_BG");

const chartId = "object.mekkochart";
const fontResolver = createFontResolver({
theme: env.sense?.theme,
Expand Down Expand Up @@ -145,13 +142,12 @@ export default function ext(env) {
settings: {
uses: "settings",
items: {
presentation: stylingPanelEnabled && {
presentation: {
type: "items",
translation: "properties.presentation",
grouped: true,
items: {
styleEditor: getStylingPanelDefinition(
bkgOptionsEnabled,
env.flags,
env.sense.theme,
fontResolver,
Expand Down
4 changes: 2 additions & 2 deletions src/pic-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export default function picDefinition({
label: getLegendLabelStyle(theme, layout, flags),
},
});
const axisLabelStyle = getAxisLabelStyle(theme, layout, flags);
const valueLabelStyle = getValueLabelStyle(theme, layout, flags);
const axisLabelStyle = getAxisLabelStyle(theme, layout);
const valueLabelStyle = getValueLabelStyle(theme, layout);
const allowTooltip = !constraints.passive;

return {
Expand Down
50 changes: 24 additions & 26 deletions src/styling-panel-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,31 @@ import { labelStylingDefinition } from "./styling-utils";
const getStylingItems = (flags, theme, fontResolver, chartId) => {
const items = {};

if (flags.isEnabled("CLIENT_IM_2022")) {
items.axisLabelSection = {
translation: "properties.axis.label",
component: "panel-section",
items: {
labelSection: {
component: "items",
ref: "components",
key: "axis",
items: labelStylingDefinition("axis.label.name", fontResolver, chartId, theme),
},
items.axisLabelSection = {
translation: "properties.axis.label",
component: "panel-section",
items: {
labelSection: {
component: "items",
ref: "components",
key: "axis",
items: labelStylingDefinition("axis.label.name", fontResolver, chartId, theme),
},
};
},
};

items.valueLabelSection = {
translation: "properties.value.label",
component: "panel-section",
items: {
labelSection: {
component: "items",
ref: "components",
key: "value",
items: labelStylingDefinition("label.value", fontResolver, chartId, theme),
},
items.valueLabelSection = {
translation: "properties.value.label",
component: "panel-section",
items: {
labelSection: {
component: "items",
ref: "components",
key: "value",
items: labelStylingDefinition("label.value", fontResolver, chartId, theme),
},
};
}
},
};

if (flags.isEnabled("CLIENT_IM_3051")) {
items.legendTitleSection = {
Expand Down Expand Up @@ -63,14 +61,14 @@ const getStylingItems = (flags, theme, fontResolver, chartId) => {
return Object.keys(items).length > 0 ? items : undefined;
};

const getStylingPanelDefinition = (bkgOptionsEnabled, flags, theme, fontResolver, chartId) => ({
const getStylingPanelDefinition = (flags, theme, fontResolver, chartId) => ({
component: "styling-panel",
chartTitle: "Object.MekkoChart",
translation: "LayerStyleEditor.component.styling",
subtitle: "LayerStyleEditor.component.styling",
ref: "components",
useGeneral: true,
useBackground: bkgOptionsEnabled,
useBackground: true,
items: getStylingItems(flags, theme, fontResolver, chartId),
});

Expand Down
8 changes: 4 additions & 4 deletions src/styling-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const labelStylingDefinition = (path, fontResolver, chartId, theme) => {
};
};

export const getAxisLabelStyle = (theme, layout, flags) => {
const axis = flags.isEnabled("CLIENT_IM_2022") ? (layout.components || []).find((c) => c.key === "axis") : {};
export const getAxisLabelStyle = (theme, layout) => {
const axis = (layout.components || []).find((c) => c.key === "axis");
return axis && axis.axis && axis.axis.label && axis.axis.label.name
? {
fontSize: axis.axis.label.name.fontSize,
Expand All @@ -52,8 +52,8 @@ export const getAxisLabelStyle = (theme, layout, flags) => {
: {};
};

export const getValueLabelStyle = (theme, layout, flags) => {
const valueLabel = flags.isEnabled("CLIENT_IM_2022") ? (layout.components || []).find((c) => c.key === "value") : {};
export const getValueLabelStyle = (theme, layout) => {
const valueLabel = (layout.components || []).find((c) => c.key === "value");
return valueLabel && valueLabel.label && valueLabel.label.value
? {
fontFamily: valueLabel.label.value.fontFamily,
Expand Down

0 comments on commit 6c07b55

Please sign in to comment.