Skip to content

Commit

Permalink
feat(llm): change ui of content card to fit with design
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasWerey committed Mar 27, 2024
1 parent ebb45be commit 622c67a
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-phones-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": patch
---

change ui of braze content cards grid layout. The grid layout will now be stacking action cards. The padding between cards has been also changed
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ import { useTheme } from "styled-components/native";
import { ContentLayoutBuilder } from "~/contentCards/layouts/utils";
import Pagination from "./pagination";
import { ContentCardItem } from "~/contentCards/cards/types";

export enum WidthFactor {
Full = 1,
Half = 0.5,
ThreeQuarters = 0.72,
}
import { WidthFactor } from "~/contentCards/layouts/types";

type Props = {
styles?: {
Expand All @@ -30,7 +25,7 @@ type Props = {
const defaultStyles = {
gap: 6,
pagination: true,
widthFactor: 1,
widthFactor: WidthFactor.Full,
};

const Carousel = ContentLayoutBuilder<Props>(({ items, styles: _styles = defaultStyles }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@ import React from "react";
import { useWindowDimensions } from "react-native";
import { ContentLayoutBuilder } from "~/contentCards/layouts/utils";
import { Flex } from "@ledgerhq/native-ui";
import { WidthFactor } from "~/contentCards/layouts/types";

type Props = {
styles?: {
gap?: number;
widthFactor?: WidthFactor;
};
};

const defaultStyles = {
gap: 6,
gap: 12,
widthFactor: WidthFactor.Half,
};

const Grid = ContentLayoutBuilder<Props>(({ items, styles: _styles = defaultStyles }) => {
const styles = {
gap: _styles.gap ?? defaultStyles.gap,
widthFactor: _styles.widthFactor ?? defaultStyles.widthFactor,
};

const width = useWindowDimensions().width / 2 - 20;
const width = useWindowDimensions().width * styles.widthFactor - 20;

return (
<Flex
Expand Down
6 changes: 6 additions & 0 deletions apps/ledger-live-mobile/src/contentCards/layouts/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ import { ContentCardItem, ContentCardProps } from "~/contentCards/cards/types";
export interface ContentLayoutProps<T extends ContentCardProps> {
items: ContentCardItem<T>[];
}

export enum WidthFactor {
Full = 1,
Half = 0.5,
ThreeQuarters = 0.72,
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
mapAsBigSquareContentCard,
mapAsHeroContentCard,
} from "~/dynamicContent/utils";
import Carousel, { WidthFactor } from "../../contentCards/layouts/carousel";
import Carousel from "../../contentCards/layouts/carousel";
import { WidthFactor } from "~/contentCards/layouts/types";
import useDynamicContent from "../useDynamicContent";
import { ContentCardsType } from "../types";
import Grid from "~/contentCards/layouts/grid";
Expand Down Expand Up @@ -127,7 +128,7 @@ const Layout = ({ category, cards }: LayoutProps) => {
/>
);
case ContentCardsLayout.grid:
return <Grid items={items} />;
return <Grid items={items} styles={{ widthFactor: cardsSorted[0].gridWidthFactor }} />;
case ContentCardsLayout.unique:
default:
return <Flex mx={6}>{items[0].component(items[0].props)}</Flex>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const ContentCardsLocation = ({ locationId, ...containerProps }: Props) => {
data={categoriesFormatted}
renderItem={Category}
keyExtractor={(item: CategoriesWithCards) => item.category.id}
ItemSeparatorComponent={() => <Flex height={8} />}
ItemSeparatorComponent={() => <Flex height={32} />}
/>
</Flex>
);
Expand Down
4 changes: 3 additions & 1 deletion apps/ledger-live-mobile/src/dynamicContent/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ContentCard as BrazeContentCard } from "@braze/react-native-sdk";
import { Size } from "~/contentCards/cards/vertical/types";
import { WidthFactor } from "~/contentCards/layouts/carousel";
import { WidthFactor } from "~/contentCards/layouts/types";

enum ContentCardsType {
smallSquare = "small_square",
Expand Down Expand Up @@ -39,6 +39,7 @@ type ContentCardCommonProperties = {
viewed: boolean;
order?: number;
carouselWidthFactor?: WidthFactor;
gridWidthFactor?: WidthFactor;
};

type CategoryContentCard = ContentCardCommonProperties & {
Expand Down Expand Up @@ -91,6 +92,7 @@ type HorizontalContentCard = ContentCardCommonProperties & {
link?: string;
description?: string;
image?: string;
gridWidthFactor?: WidthFactor;
};

type HeroContentCard = ContentCardCommonProperties & {
Expand Down
3 changes: 2 additions & 1 deletion apps/ledger-live-mobile/src/dynamicContent/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Size } from "~/contentCards/cards/vertical/types";
import { WidthFactor } from "~/contentCards/layouts/carousel";
import { WidthFactor } from "~/contentCards/layouts/types";
import {
BrazeContentCard,
AssetContentCard,
Expand Down Expand Up @@ -144,6 +144,7 @@ export const mapAsHorizontalContentCard = (card: BrazeContentCard): HorizontalCo
createdAt: card.created,
viewed: card.viewed,
order: parseInt(card.extras.order) ? parseInt(card.extras.order) : undefined,
gridWidthFactor: WidthFactor.Full,
});

const mapAsSquareContentCard = (
Expand Down

0 comments on commit 622c67a

Please sign in to comment.