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(Cross): [IOAPPX-448] Add missing components to the Design System section, remove legacy ones + Change ListItemMessage component API #6541

Merged
merged 31 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
961e91b
Update `BannerErrorState`, add it to the `DSAdvice`
dmnplb Dec 11, 2024
558b9f8
Rename `DoubleAvatar` to `AvatarDouble`, add it to `DSLogos`
dmnplb Dec 11, 2024
9d943c1
Merge branch 'master' into IOAPPX-448-update-ds-documentation
dmnplb Dec 13, 2024
38429d5
Replace `H2` with `H3` in the Design System main navigation
dmnplb Dec 13, 2024
81079d9
Rename `MessageListItem` to `ListItemMessage` for naming convention
dmnplb Dec 13, 2024
1b48f3b
Remove `CustomPressableListItemBase` by integrating it into `ListItem…
dmnplb Dec 13, 2024
161779e
Add `ListItemMessage` to `DSListItems` page
dmnplb Dec 13, 2024
12ff47e
Remove CGN gradients from `DSColors`
dmnplb Dec 13, 2024
956d5c3
Merge branch 'master' into IOAPPX-448-update-ds-documentation
LeleDallas Dec 13, 2024
381f350
Merge branch 'master' into IOAPPX-448-update-ds-documentation
dmnplb Dec 13, 2024
f34e1fa
Merge branch 'master' into IOAPPX-448-update-ds-documentation
dmnplb Dec 16, 2024
d662200
Add `flexWrap` property to `DSTypography`
dmnplb Dec 16, 2024
f846ce8
Merge branch 'master' into IOAPPX-448-update-ds-documentation
LeleDallas Dec 16, 2024
c5ea5b9
Merge branch 'master' into IOAPPX-448-update-ds-documentation
LeleDallas Dec 16, 2024
6b9e1ae
Merge branch 'master' into IOAPPX-448-update-ds-documentation
dmnplb Dec 16, 2024
006839b
Merge branch 'master' into IOAPPX-448-update-ds-documentation
dmnplb Dec 17, 2024
dc33be6
Improve `ListItemMessage` component API
dmnplb Dec 17, 2024
6b3f740
Update `jest` snapshot
dmnplb Dec 17, 2024
905c25b
Add `ListItemSearchInstitution` to the `DSListItems`
dmnplb Dec 17, 2024
001d1a2
Add new variant of `ListItemNav` not documented
dmnplb Dec 17, 2024
2d98122
Rename `CgnModuleDiscount` into `ModuleCgnDiscount`, move it into `DS…
dmnplb Dec 17, 2024
035841c
Merge branch 'master' into IOAPPX-448-update-ds-documentation
dmnplb Dec 17, 2024
17523d1
Update `jest` snapshot
dmnplb Dec 17, 2024
462687f
Merge branch 'master' into IOAPPX-448-update-ds-documentation
dmnplb Dec 17, 2024
19ce1dc
Merge branch 'master' into IOAPPX-448-update-ds-documentation
dmnplb Dec 18, 2024
93f9020
Merge branch 'master' into IOAPPX-448-update-ds-documentation
CrisTofani Dec 18, 2024
1ddd447
Restore generic `IOIcons` type in the `BannerErrorState` component
dmnplb Dec 18, 2024
04e6edc
Merge branch 'master' into IOAPPX-448-update-ds-documentation
dmnplb Dec 19, 2024
2775fb1
Merge branch 'master' into IOAPPX-448-update-ds-documentation
dmnplb Dec 19, 2024
34694fa
Merge branch 'master' into IOAPPX-448-update-ds-documentation
Vangaorth Dec 19, 2024
f2aae62
Merge branch 'master' into IOAPPX-448-update-ds-documentation
dmnplb Dec 19, 2024
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
2 changes: 1 addition & 1 deletion ts/components/ui/BannerErrorState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export type BannerErrorStateProps = BaseBannerErrorStateProps &
*/
export const BannerErrorState = ({
viewRef,
icon,
icon = "warningFilled",
label,
actionText,
onPress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CGN_ROUTES from "../../navigation/routes";
import { CgnDetailsParamsList } from "../../navigation/params";
import { useIODispatch } from "../../../../../store/hooks";
import { selectMerchantDiscount } from "../../store/actions/merchants";
import { CgnModuleDiscount } from "./CgnModuleDiscount";
import { ModuleCgnDiscount } from "./ModuleCgnDiscount";

type Props = {
discount: Discount;
Expand Down Expand Up @@ -38,7 +38,7 @@ export const CgnMerchantDiscountItem: React.FunctionComponent<Props> = ({

return (
<View style={styles.container}>
<CgnModuleDiscount onPress={onDiscountPress} discount={discount} />
<ModuleCgnDiscount onPress={onDiscountPress} discount={discount} />
</View>
);
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
Badge,
H6,
HSpacer,
HStack,
IOColors,
IOModuleStyles,
IOStyles,
Icon,
Tag,
VSpacer,
useIOExperimentalDesign,
VStack,
useIOTheme,
useScaleAnimation
} from "@pagopa/io-app-design-system";
import * as O from "fp-ts/lib/Option";
Expand All @@ -21,7 +21,7 @@ import I18n from "../../../../../i18n";
import { getCategorySpecs } from "../../utils/filters";
import { isValidDiscount, normalizedDiscountPercentage } from "./utils";

type Props = {
export type ModuleCgnDiscount = {
onPress: () => void;
discount: Discount;
};
Expand All @@ -39,6 +39,7 @@ const styles = StyleSheet.create({
borderWidth: 1
}
});

type CategoryTagProps = {
category: ProductCategory;
};
Expand All @@ -47,24 +48,19 @@ export const CategoryTag = ({ category }: CategoryTagProps) => {
const categorySpecs = getCategorySpecs(category);

return O.isSome(categorySpecs) ? (
<>
<View>
<Tag
text={I18n.t(categorySpecs.value.nameKey)}
variant="custom"
icon={{
name: categorySpecs.value.icon,
color: "lightGrey"
}}
/>
<VSpacer size={4} />
</View>
<HSpacer size={4} />
</>
<Tag
text={I18n.t(categorySpecs.value.nameKey)}
variant="custom"
icon={{
name: categorySpecs.value.icon,
color: "lightGrey"
}}
/>
) : null;
};
export const CgnModuleDiscount = ({ onPress, discount }: Props) => {
const { isExperimental } = useIOExperimentalDesign();

export const ModuleCgnDiscount = ({ onPress, discount }: ModuleCgnDiscount) => {
const theme = useIOTheme();
const { onPressIn, onPressOut, scaleAnimatedStyle } =
useScaleAnimation("medium");

Expand Down Expand Up @@ -92,37 +88,37 @@ export const CgnModuleDiscount = ({ onPress, discount }: Props) => {
{ alignItems: "center", justifyContent: "space-between" }
]}
>
<View style={IOStyles.flex}>
<View style={[IOStyles.flex, IOStyles.row]}>
{discount.isNew && (
<>
<VStack space={8} style={{ flexShrink: 1 }}>
{(discount.discount || discount.isNew) && (
<HStack space={8} style={{ flexWrap: "wrap" }}>
{discount.isNew && (
<Badge
variant="purple"
text={I18n.t("bonus.cgn.merchantsList.news")}
/>
<HSpacer size={8} />
</>
)}
{isValidDiscount(discount.discount) && (
<Badge
variant="purple"
outline
text={`-${normalizedDiscountPercentage(discount.discount)}%`}
/>
)}
</View>
<VSpacer size={8} />
)}
{isValidDiscount(discount.discount) && (
<Badge
variant="purple"
outline
text={`-${normalizedDiscountPercentage(
discount.discount
)}%`}
/>
)}
</HStack>
)}

<H6>{discount.name}</H6>
<VSpacer size={8} />
<View style={[{ flexWrap: "wrap" }, IOStyles.row]}>
<HStack space={4} style={{ flexWrap: "wrap" }}>
{discount.productCategories.map(categoryKey => (
<CategoryTag key={categoryKey} category={categoryKey} />
))}
</View>
</View>
</HStack>
</VStack>
<Icon
name="chevronRightListItem"
color={isExperimental ? "blueIO-500" : "blue"}
color={theme["interactiveElem-default"]}
size={24}
/>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from "react";
import { Discount } from "../../../../../../../definitions/cgn/merchants/Discount";
import { ProductCategoryEnum } from "../../../../../../../definitions/cgn/merchants/ProductCategory";
import I18n from "../../../../../../i18n";
import { CgnModuleDiscount } from "../CgnModuleDiscount";
import { ModuleCgnDiscount } from "../ModuleCgnDiscount";

describe("CgnModuleDiscount", () => {
const discount: Discount = {
Expand All @@ -27,7 +27,7 @@ describe("CgnModuleDiscount", () => {

it("should render correctly", () => {
const { getByText } = render(
<CgnModuleDiscount onPress={onPressMock} discount={discount} />
<ModuleCgnDiscount onPress={onPressMock} discount={discount} />
);

expect(getByText(I18n.t("bonus.cgn.merchantsList.news"))).toBeTruthy();
Expand All @@ -37,7 +37,7 @@ describe("CgnModuleDiscount", () => {

it("should call onPress when pressed", () => {
const { getByRole } = render(
<CgnModuleDiscount onPress={onPressMock} discount={discount} />
<ModuleCgnDiscount onPress={onPressMock} discount={discount} />
);
fireEvent.press(getByRole("button"));
expect(onPressMock).toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
Badge,
H3,
HStack,
IOColors,
IOStyles,
VSpacer
Expand All @@ -10,7 +11,7 @@ import React from "react";
import { StyleSheet, View } from "react-native";
import { Discount } from "../../../../../../../definitions/cgn/merchants/Discount";
import I18n from "../../../../../../i18n";
import { CategoryTag } from "../CgnModuleDiscount";
import { CategoryTag } from "../ModuleCgnDiscount";
import { isValidDiscount, normalizedDiscountPercentage } from "../utils";

type CgnDiscountHeaderProps = {
Expand Down Expand Up @@ -65,11 +66,11 @@ export const CgnDiscountHeader = ({
)}
<H3>{name}</H3>
<VSpacer size={12} />
<View style={[{ flexWrap: "wrap" }, IOStyles.row]}>
<HStack space={4} style={{ flexWrap: "wrap" }}>
{productCategories.map(categoryKey => (
<CategoryTag key={categoryKey} category={categoryKey} />
))}
</View>
</HStack>
</View>
</View>
);
Expand Down
8 changes: 5 additions & 3 deletions ts/features/design-system/DesignSystem.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
BodySmall,
Divider,
H2,
H3,
IOVisualCostants,
BodySmall,
ListItemNav,
VSpacer,
VStack,
Expand Down Expand Up @@ -109,7 +109,9 @@ export const DesignSystem = () => {
section: { title: string; description?: string };
}) => (
<VStack space={4}>
<H2 color={theme["textHeading-default"]}>{title}</H2>
<H3 weight="Bold" color={theme["textHeading-default"]}>
{title}
</H3>
{description && (
<BodySmall weight={"Regular"} color={theme["textBody-tertiary"]}>
{description}
Expand Down
26 changes: 26 additions & 0 deletions ts/features/design-system/core/DSAdvice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as React from "react";
import { Alert } from "react-native";
import { DSComponentViewerBox } from "../components/DSComponentViewerBox";
import { DesignSystemScreen } from "../components/DesignSystemScreen";
import { BannerErrorState } from "../../../components/ui/BannerErrorState";

const onLinkPress = () => {
Alert.alert("Alert", "Action triggered");
Expand All @@ -35,6 +36,11 @@ export const DSAdvice = () => {
{renderFeatureInfo()}
</VStack>

<VStack space={sectionTitleMargin}>
<H4 color={theme["textHeading-default"]}>BannerErrorState</H4>
{renderBannerErrorState()}
</VStack>

<VStack space={sectionTitleMargin}>
<H4 color={theme["textHeading-default"]}>Banner</H4>
{renderBanner()}
Expand All @@ -44,6 +50,26 @@ export const DSAdvice = () => {
);
};

const renderBannerErrorState = () => (
<VStack space={componentMargin}>
<DSComponentViewerBox name="BannerErrorState, default icon">
<BannerErrorState
label="Il caricamento delle ricevute è fallito."
actionText={"Riprova"}
onPress={onLinkPress}
/>
</DSComponentViewerBox>
<DSComponentViewerBox name="BannerErrorState, custom icon">
<BannerErrorState
icon="errorFilled"
label="Il caricamento delle ricevute è fallito."
actionText={"Riprova"}
onPress={onLinkPress}
/>
</DSComponentViewerBox>
</VStack>
);

const renderFeatureInfo = () => (
<VStack space={componentMargin}>
<DSComponentViewerBox name="FeatureInfo · with Icon">
Expand Down
Loading
Loading