Skip to content
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
57 changes: 47 additions & 10 deletions app/client/src/layoutSystems/anvil/common/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,72 @@
[data-elevation] — true or false, indicates whether elevation is enabled or not
[elevation="1"] — section
[elevation="2"] — zone
[elevation="3"] — card
*/
.anvilWidgetWrapper {
/** If a section or zone have elevation, then add padding */
/** If a section,zone and card have elevation, then add padding */
[data-elevation="true"][elevation="1"],
[data-elevation="true"][elevation="2"],
[elevation="1"]:has([data-elevation="true"]) [data-elevation="false"] {
[data-elevation="true"][elevation="3"],
/** If a section has any zone with elevation, then add padding to all the zones that don't have elevation */
[elevation="1"]:has([elevation="2"][data-elevation="true"]) [elevation="2"][data-elevation="false"],
/** If a section has any card with elevation, then add padding to all the cards that don't have elevation */
[elevation="1"]:has([elevation="3"][data-elevation="true"]) [elevation="3"][data-elevation="false"],
/** If a zone has any card with elevation, then add padding to all the cards that don't have elevation,*/
[elevation="2"]:has([elevation="3"][data-elevation="true"]) [elevation="3"][data-elevation="false"] {
padding-block: var(--outer-spacing-3);
padding-inline: var(--outer-spacing-3);
}

/**also we want to adding margin to the widgets as well that are not cards, this is required to align widgets with elevations of cards */
[elevation="2"]:has([elevation="3"][data-elevation="true"])
[data-widget-wrapper]:not(:has([data-elevation])) {
margin-block: var(--outer-spacing-3);
margin-inline: var(--outer-spacing-3);
}

[data-elevation="false"][elevation="2"] {
min-height: var(--sizing-8);
}

/**
1. Styles for the section if elevation is enabled only for section
2. Styles for the zone if elevation is enabled
*/
[data-elevation="true"][elevation="1"]:has([data-elevation="false"]),
[data-elevation="true"][elevation="2"] {
/** by default, sections/zone/cards with elevation have styles 1 */
[data-elevation="true"][elevation="1"],
[data-elevation="true"][elevation="2"],
[data-elevation="true"][elevation="3"] {
background-color: var(--color-bg-elevation-2);
border-radius: var(--border-radius-elevation-2);
outline: var(--border-width-1) solid var(--color-bd-elevation-2);
}

/** Styles for the section if elevation is enabled for both section and zone */
[data-elevation="true"][elevation="1"]:has([data-elevation="true"]) {
/** when there are two elevation levels, then add styles-1 -> the first level and styles-2 -> second level */
[data-elevation="true"]:has([data-elevation="true"]) {
background-color: var(--color-bg-elevation-1);
border-radius: var(--border-radius-elevation-1);
outline: var(--border-width-1) solid var(--color-bd-elevation-1);

[data-elevation="true"] {
background-color: var(--color-bg-elevation-2);
border-radius: var(--border-radius-elevation-2);
outline: var(--border-width-1) solid var(--color-bd-elevation-2);
}
}

/** when there are three elevation levels, then add styles-1 -> the first level and styles-2 -> second level and styles-3 -> third level */
[data-elevation="true"]:has([data-elevation="true"] [data-elevation="true"]) {
background-color: var(--color-bg-elevation-1);
border-radius: var(--border-radius-elevation-1);
outline: var(--border-width-1) solid var(--color-bd-elevation-1);

[data-elevation="true"] {
background-color: var(--color-bg-elevation-2);
border-radius: var(--border-radius-elevation-2);
outline: var(--border-width-1) solid var(--color-bd-elevation-2);

[data-elevation="true"] {
background-color: var(--color-bg-elevation-3);
border-radius: var(--border-radius-elevation-3);
outline: var(--border-width-1) solid var(--color-bd-elevation-3);
}
}
}
}
3 changes: 2 additions & 1 deletion app/client/src/sagas/WidgetAdditionSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ export function getWidgetSessionValues(

let widgetType = type;
const configMap = WidgetFactory.widgetConfigMap.get(type);

const widgetSessionValues: any = {};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify a more precise type instead of any.

- const widgetSessionValues: any = {};
+ const widgetSessionValues: Record<string, unknown> = {}; // Use a more specific type if possible.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
const widgetSessionValues: any = {};
const widgetSessionValues: Record<string, unknown> = {}; // Use a more specific type if possible.


// in case we are dropping WDS_ICON_BUTTON_WIDGET, we want to reuse the values of BUTTON_WIDGET
Expand All @@ -552,7 +553,7 @@ export function getWidgetSessionValues(
}

for (const key in configMap) {
if (configMap[key]) {
if (configMap[key] != undefined) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use strict inequality operator !== instead of !=.

- if (configMap[key] != undefined) {
+ if (configMap[key] !== undefined) {

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if (configMap[key] != undefined) {
if (configMap[key] !== undefined) {

let sessionStorageKey = `${widgetType}.${key}`;

if (type === "ZONE_WIDGET") {
Expand Down
1 change: 1 addition & 0 deletions app/client/src/widgets/anvil/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const anvilWidgets = {
export enum Elevations {
SECTION_ELEVATION = 1,
ZONE_ELEVATION = 2,
CARD_ELEVATION = 3,
}

/**
Expand Down
4 changes: 2 additions & 2 deletions app/client/src/widgets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import { ZoneWidget } from "./anvil/ZoneWidget";
import { WDSHeadingWidget } from "./wds/WDSHeadingWidget";
import { WDSParagraphWidget } from "./wds/WDSParagraphWidget";
import { WDSModalWidget } from "./wds/WDSModalWidget";
import { WDSStatBoxWidget } from "./wds/WDSStatBoxWidget";
import { WDSStatsWidget } from "./wds/WDSStatsWidget";
import { WDSKeyValueWidget } from "./wds/WDSKeyValueWidget";
import { WDSInlineButtonsWidget } from "./wds/WDSInlineButtonsWidget";

Expand Down Expand Up @@ -170,7 +170,7 @@ const WDSWidgets = [
WDSParagraphWidget,
WDSHeadingWidget,
WDSModalWidget,
WDSStatBoxWidget,
WDSStatsWidget,
WDSKeyValueWidget,
WDSInlineButtonsWidget,
];
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions app/client/src/widgets/wds/WDSStatBoxWidget/index.tsx

This file was deleted.

55 changes: 0 additions & 55 deletions app/client/src/widgets/wds/WDSStatBoxWidget/widget/index.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import React from "react";
import type { StatBoxComponentProps } from "./types";
import type { StatsComponentProps } from "./types";

import styles from "./styles.module.css";
import { Flex, Icon, Text } from "@design-system/widgets";

export const StatBoxComponent = (props: StatBoxComponentProps) => {
export const StatsComponent = (props: StatsComponentProps) => {
const {
caption,
iconAlign,
iconName,
label,
sublabel,
onClick,
value,
valueChange,
valueImpact,
valueChangeColor,
valueColor,
} = props;

return (
<Flex
alignItems="center"
className={styles.statbox}
direction={iconAlign === "end" ? "row-reverse" : "row"}
gap="spacing-2"
isInner
onClick={onClick}
>
{iconName && iconName !== "(none)" && (
<Icon name={iconName} size="large" />
Expand All @@ -40,19 +41,24 @@ export const StatBoxComponent = (props: StatBoxComponentProps) => {
isInner
maxWidth="calc(100% - var(--sizing-1))"
>
<Text fontWeight={500} lineClamp={1} size="subtitle">
<Text
color={valueColor}
fontWeight={500}
lineClamp={1}
size="subtitle"
>
{value}
</Text>
{valueChange && (
<Text color={valueImpact} lineClamp={1} size="footnote">
<Text color={valueChangeColor} lineClamp={1} size="footnote">
{valueChange}
</Text>
)}
</Flex>
)}
{sublabel && (
{caption && (
<Text color="neutral" lineClamp={1} size="footnote">
{sublabel}
{caption}
</Text>
)}
</Flex>
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions app/client/src/widgets/wds/WDSStatsWidget/component/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { StatsWidgetProps } from "../widget/types";

export interface StatsComponentProps extends StatsWidgetProps {}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import type { AnvilConfig } from "WidgetProvider/constants";

export const anvilConfig: AnvilConfig = {
isLargeWidget: true,
isLargeWidget: false,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not enough because ResponsiveBehavior should be changed to hug. The idea here is to be able to have multiple StatsWidget in the same zone.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CleanShot 2024-05-24 at 14 09 56@2x Fill or Hug? 😵‍💫 We have the `ResponsiveBehaviour.Fill` for statbox in our `src/widgets/wds/WDSStatsWidget/config/defaultsConfig.ts`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm a little confused about the terminology. Fill widget is the correct behavior, but as far as I can see, it does not work correctly.
Here's what we have:
Снимок экрана 2024-05-24 в 12 18 01

And for example, how inputs works:
Снимок экрана 2024-05-24 в 12 17 44

So Stats should behave the same way.

widgetSize: {
minWidth: "100%",
minWidth: {
base: "100%",
"180px": "sizing-30",
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import { ResponsiveBehavior } from "layoutSystems/common/utils/constants";

export const defaultsConfig = {
isVisible: true,
widgetName: "StatBoxWidget",
widgetName: "StatsWidget",
version: 1,
animateLoading: true,
valueImpact: "positive",
valueColor: "neutral",
valueChange: "+50%",
valueChangeColor: "positive",
value: "42",
label: "Active Users",
sublabel: "This week",
caption: "This week",
iconName: "shopping-bag",
responsiveBehavior: ResponsiveBehavior.Fill,
elevatedBackground: false,
} as unknown as WidgetDefaultProps;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WIDGET_TAGS } from "constants/WidgetConstants";

export const metaConfig = {
name: "Statbox",
name: "Stats",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just wondering why the name was changed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was there in list of things we need to do in the polish.

needsMeta: false,
isCanvas: false,
searchTags: ["statbox"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,32 @@ export const propertyPaneContentConfig = [
label: "Value",
helpText: "Sets the value of the statbox",
controlType: "INPUT_TEXT",
placeholderText: "257",
placeholderText: "42",
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.TEXT },
},
{
propertyName: "valueColor",
label: "Value color",
controlType: "DROP_DOWN",
fullWidth: true,
helpText: "Emphasizes the value's semantic impact",
options: Object.values(COLORS).map((semantic) => ({
label: capitalize(semantic),
value: semantic,
})),
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: false,
validation: {
type: ValidationTypes.TEXT,
params: {
allowedValues: Object.values(COLORS),
default: COLORS.accent,
},
},
},
],
},
{
Expand Down Expand Up @@ -74,14 +95,14 @@ export const propertyPaneContentConfig = [
label: "Value change",
helpText: "Secondary information about the value",
controlType: "INPUT_TEXT",
placeholderText: "+146%",
placeholderText: "+50%",
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.TEXT },
},
{
propertyName: "valueImpact",
label: "Impact",
propertyName: "valueChangeColor",
label: "Color",
controlType: "DROP_DOWN",
fullWidth: true,
helpText: "Emphasizes the change's semantic impact",
Expand All @@ -101,9 +122,9 @@ export const propertyPaneContentConfig = [
},
},
{
propertyName: "sublabel",
label: "Sub label",
helpText: "Sets the sublabel of the statbox",
propertyName: "caption",
label: "Caption",
helpText: "Sets the caption of the statbox",
controlType: "INPUT_TEXT",
placeholderText: "Since 21 Jan 2022",
isBindProperty: true,
Expand Down Expand Up @@ -138,4 +159,18 @@ export const propertyPaneContentConfig = [
},
],
},
{
sectionName: "Events",
children: [
{
helpText: "when the button is clicked",
propertyName: "onClick",
label: "onClick",
controlType: "ACTION_SELECTOR",
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: true,
},
],
},
];
Loading