Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

chore(CollectionShare):remove-weekday-to-prevent-wrap-on-link-expire

Aswin Asok466cf40a99b6
diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsx
index 0442d88220..9ff9efa81e 100644
--- a/web/apps/photos/src/components/Collections/CollectionShare.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx
@@ -1998,7 +1998,6 @@ const ManageLinkExpiry: React.FC<ManagePublicLinkSettingDrawerProps> = ({
onClick={showExpiryOptions}
endIcon={<ChevronRightIcon />}
label={t("link_expiry")}
- captionVariant="mini"
color={
isLinkExpired(publicURL.validTill)
? "critical"
@@ -2008,7 +2007,9 @@ const ManageLinkExpiry: React.FC<ManagePublicLinkSettingDrawerProps> = ({
isLinkExpired(publicURL.validTill)
? t("link_expired")
: publicURL.validTill
- ? formattedDateTime(publicURL.validTill)
+ ? formattedDateTime(publicURL.validTill, {
+ omitWeekdayWhenYearIncluded: true,
+ })
: t("never")
}
/>
diff --git a/web/packages/base/components/RowButton.tsx b/web/packages/base/components/RowButton.tsx
index 3c0c6c62fa..a66bec3e42 100644
--- a/web/packages/base/components/RowButton.tsx
+++ b/web/packages/base/components/RowButton.tsx
@@ -200,12 +200,6 @@ interface RowButtonProps {
* if it is not a string.
*/
caption?: React.ReactNode;
- /**
- * The typography variant to use for the caption, when present.
- *
- * Default: "small".
- */
- captionVariant?: TypographyProps["variant"];
}
/**
@@ -222,7 +216,6 @@ export const RowButton: React.FC<RowButtonProps> = ({
endIcon,
label,
caption,
- captionVariant = "small",
onClick,
}) => (
<RowButtonRoot rbVariant={variant} fullWidth {...{ disabled, onClick }}>
@@ -262,10 +255,7 @@ export const RowButton: React.FC<RowButtonProps> = ({
<CaptionTypography color={color}>
{"β€’"}
</CaptionTypography>
- <CaptionTypography
- color={color}
- variant={captionVariant}
- >
+ <CaptionTypography color={color}>
{caption}
</CaptionTypography>
</Stack>
@@ -314,13 +304,10 @@ const RowButtonRoot = styled(FocusVisibleButton, {
}));
const CaptionTypography: React.FC<
- React.PropsWithChildren<{
- color: RowButtonProps["color"];
- variant?: TypographyProps["variant"];
- }>
-> = ({ color, variant = "small", children }) => (
+ React.PropsWithChildren<{ color: RowButtonProps["color"] }>
+> = ({ color, children }) => (
<Typography
- variant={variant}
+ variant="small"
sx={[
color == "critical"
? { color: "critical.main" }
diff --git a/web/packages/base/i18n-date.ts b/web/packages/base/i18n-date.ts
index 05cc4fd8af..b49d472520 100644
--- a/web/packages/base/i18n-date.ts
+++ b/web/packages/base/i18n-date.ts
@@ -13,6 +13,12 @@ const _dateFormat = new Intl.DateTimeFormat(i18n.language, {
year: "numeric",
});
+const _dateWithoutWeekdayFormat = new Intl.DateTimeFormat(i18n.language, {
+ day: "numeric",
+ month: "short",
+ year: "numeric",
+});
+
const _dateWithoutYearFormat = new Intl.DateTimeFormat(i18n.language, {
weekday: "short",
day: "numeric",
@@ -23,6 +29,10 @@ const _timeFormat = new Intl.DateTimeFormat(i18n.language, {
timeStyle: "short",
});
+interface FormattedDateOptions {
+ omitWeekdayWhenYearIncluded?: boolean;
+}
+
/**
* Return a locale aware formatted date from the given {@link Date}.
*
@@ -33,8 +43,14 @@ const _timeFormat = new Intl.DateTimeFormat(i18n.language, {
*
* - Otherwise, the year is included, e.g., "Fri, 21 Feb 2025".
*/
-export const formattedDate = (date: Date) =>
- (isSameYear(date) ? _dateWithoutYearFormat : _dateFormat).format(date);
+export const formattedDate = (date: Date, options?: FormattedDateOptions) =>
+ (
+ isSameYear(date)
+ ? _dateWithoutYearFormat
+ : options?.omitWeekdayWhenYearIncluded
+ ? _dateWithoutWeekdayFormat
+ : _dateFormat
+ ).format(date);
const isSameYear = (date: Date) =>
new Date().getFullYear() === date.getFullYear();
@@ -66,11 +82,13 @@ export const formattedTime = (date: Date) => _timeFormat.format(date);
* date, or it can be given the raw epoch microseconds value and it'll convert
* internally.
*/
-export const formattedDateTime = (dateOrEpochMicroseconds: Date | number) =>
- _formattedDateTime(toDate(dateOrEpochMicroseconds));
+export const formattedDateTime = (
+ dateOrEpochMicroseconds: Date | number,
+ options?: FormattedDateOptions,
+) => _formattedDateTime(toDate(dateOrEpochMicroseconds), options);
-const _formattedDateTime = (date: Date) =>
- [formattedDate(date), t("at"), formattedTime(date)].join(" ");
+const _formattedDateTime = (date: Date, options?: FormattedDateOptions) =>
+ [formattedDate(date, options), t("at"), formattedTime(date)].join(" ");
const toDate = (dm: Date | number) =>
typeof dm == "number" ? new Date(dm / 1000) : dm;