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

[IOPLT-317] Adds ListItemNav Calendar version #175

Merged
merged 2 commits into from
Jan 8, 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
27 changes: 21 additions & 6 deletions example/src/pages/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,11 @@ const renderListItemNav = () => (
alert("Action triggered");
}}
accessibilityLabel="Empty just for testing purposes"
badgeProps={{
text: "Novità",
variant: "blue"
topElement={{
badgeProps: {
text: "Novità",
variant: "blue"
}
}}
/>
<ListItemNav
Expand All @@ -197,12 +199,25 @@ const renderListItemNav = () => (
alert("Action triggered");
}}
accessibilityLabel="Empty just for testing purposes"
badgeProps={{
text: "Novità",
variant: "blue"
topElement={{
badgeProps: {
text: "Novità",
variant: "blue"
}
}}
hideChevron
/>
<ListItemNav
value={"Value"}
description="This is a list item nav with badge"
onPress={() => {
alert("Action triggered");
}}
accessibilityLabel="Empty just for testing purposes"
topElement={{
dateValue: "14/04/2024"
}}
/>
</View>
</ComponentViewerBox>
<ComponentViewerBox name="ListItemNavAlert">
Expand Down
44 changes: 35 additions & 9 deletions src/components/listitems/ListItemNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,18 @@ import { WithTestID } from "../../utils/types";
import { Badge } from "../badge";
import { IOIcons, Icon } from "../icons";
import { IOLogoPaymentType, LogoPayment } from "../logos";
import { VSpacer } from "../spacer";
import { H6, LabelSmall } from "../typography";
import { HSpacer, VSpacer } from "../spacer";
import { Caption, H6, LabelSmall } from "../typography";

type ListItemTopElementProps =
| {
badgeProps: React.ComponentProps<typeof Badge>;
dateValue?: never;
}
| {
badgeProps?: never;
dateValue: string;
};

type ListItemNavPartialProps = WithTestID<{
value: string | React.ReactNode;
Expand All @@ -34,7 +44,7 @@ type ListItemNavPartialProps = WithTestID<{
// Accessibility
accessibilityLabel: string;
hideChevron?: boolean;
badgeProps?: React.ComponentProps<typeof Badge>;
topElement?: ListItemTopElementProps;
}>;

export type ListItemNavGraphicProps =
Expand All @@ -54,20 +64,36 @@ export const ListItemNav = ({
accessibilityLabel,
testID,
hideChevron = false,
badgeProps
topElement
}: ListItemNav) => {
const isPressed = useSharedValue(0);
const { isExperimental } = useIOExperimentalDesign();
const theme = useIOTheme();

const listItemNavContent = (
<>
{badgeProps && (
{topElement && (
<>
<View style={{ alignSelf: "flex-start" }}>
<Badge {...badgeProps} />
</View>
<VSpacer size={4} />
{topElement.badgeProps && (
<>
<View style={{ alignSelf: "flex-start" }}>
<Badge {...topElement.badgeProps} />
</View>
<VSpacer size={8} />
</>
)}
{topElement.dateValue && (
<>
<View style={{ alignSelf: "flex-start", flexDirection: "row" }}>
<Icon name="calendar" size={16} />
<HSpacer size={4} />
<Caption color={theme["textBody-tertiary"]}>
{topElement.dateValue}
</Caption>
</View>
<VSpacer size={4} />
</>
)}
</>
)}
{/* Let developer using a custom component (e.g: skeleton) */}
Expand Down