From a0553380761fe40f9ad0336e95aa43f43ea54f0b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1s=20Francisco?=
<4301103+tomasfrancisco@users.noreply.github.com>
Date: Tue, 1 Oct 2024 14:42:40 +0200
Subject: [PATCH] fix time in widget and metadata for engine (#49)
---
apps/engine/src/lib/metadata.ts | 10 +++++++---
packages/figma-utilities/src/events.ts | 2 +-
packages/figma-widget/package.json | 2 ++
.../figma-widget/src/ui/modules/variables.ui.tsx | 2 +-
.../src/widget/components/variables.tsx | 16 +++++-----------
.../figma-widget/src/widget/modules/state.ts | 2 +-
pnpm-lock.yaml | 11 +++++++++++
7 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/apps/engine/src/lib/metadata.ts b/apps/engine/src/lib/metadata.ts
index 8e997e9f..a4ad9f4a 100644
--- a/apps/engine/src/lib/metadata.ts
+++ b/apps/engine/src/lib/metadata.ts
@@ -5,13 +5,17 @@ interface GetMetadataArgs {
title?: string;
}
-export function getMetadata({ title }: GetMetadataArgs = {}): Metadata {
+export function getMetadata({ title: _title }: GetMetadataArgs = {}): Metadata {
+ const title = `${_title ? `${_title} | ` : ''}DS Pro`;
+ const description = 'Your Design System Engine';
return {
- title: `${title ? `${title} | ` : ''}DS Pro`,
- description: 'Your Design System Engine',
+ title,
+ description,
keywords: 'design system, devops, engine, design, system, design tokens',
openGraph: {
siteName: 'DS Pro',
+ title,
+ description,
url: `${config.pageUrl}/api/og`,
images: [`${config.pageUrl}/api/og`],
},
diff --git a/packages/figma-utilities/src/events.ts b/packages/figma-utilities/src/events.ts
index 1fc11e8e..fda16844 100644
--- a/packages/figma-utilities/src/events.ts
+++ b/packages/figma-utilities/src/events.ts
@@ -34,7 +34,7 @@ type Event = Implements<
'sync-variables': {
request: { variables: DesignTokens };
response: {
- lastSyncedAt: number | null;
+ lastSyncedAt: string | null;
};
};
diff --git a/packages/figma-widget/package.json b/packages/figma-widget/package.json
index 727900be..42d54039 100644
--- a/packages/figma-widget/package.json
+++ b/packages/figma-widget/package.json
@@ -24,7 +24,9 @@
"prettier": "@ds-project/prettier",
"dependencies": {
"@create-figma-plugin/utilities": "^3.2.0",
+ "@date-fns/tz": "^1.1.2",
"@tanstack/react-query": "^5.51.24",
+ "date-fns": "^3.6.0",
"memoize": "^10.0.0",
"object-hash": "^3.0.0",
"rambda": "^9.2.1",
diff --git a/packages/figma-widget/src/ui/modules/variables.ui.tsx b/packages/figma-widget/src/ui/modules/variables.ui.tsx
index f001b73d..3cbf11f4 100644
--- a/packages/figma-widget/src/ui/modules/variables.ui.tsx
+++ b/packages/figma-widget/src/ui/modules/variables.ui.tsx
@@ -28,7 +28,7 @@ export function VariablesUI() {
});
return {
- lastSyncedAt: new Date().getTime(),
+ lastSyncedAt: new Date().toISOString(),
};
});
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: perhaps refactor handle so no more than one listener to the same message type is added
diff --git a/packages/figma-widget/src/widget/components/variables.tsx b/packages/figma-widget/src/widget/components/variables.tsx
index 90c68e81..0ea9ce5d 100644
--- a/packages/figma-widget/src/widget/components/variables.tsx
+++ b/packages/figma-widget/src/widget/components/variables.tsx
@@ -1,9 +1,10 @@
import { updateIcon } from '../icons/update';
import { AutoLayout, SVG, Text } from '../lib/widget';
import { Button } from './button';
+import { format } from 'date-fns';
interface VariablesProps {
- lastSyncedAt: number | null;
+ lastSyncedAt: string | null;
onSyncVariablesClick: () => void;
}
@@ -11,15 +12,8 @@ export function Variables({
lastSyncedAt,
onSyncVariablesClick,
}: VariablesProps) {
- const formatDate = (date: Date) => {
- return date.toLocaleString('en-GB', {
- day: '2-digit',
- month: '2-digit',
- year: 'numeric',
- hour: '2-digit',
- minute: '2-digit',
- hour12: false,
- });
+ const formatDate = (date: string) => {
+ return format(date, 'dd/MM/yyyy, HH:mm');
};
return (
@@ -41,7 +35,7 @@ export function Variables({
{lastSyncedAt
- ? `Last synced ${formatDate(new Date(lastSyncedAt))}`
+ ? `Last synced: ${formatDate(lastSyncedAt)}`
: 'This is your first time syncing 🚀'}
diff --git a/packages/figma-widget/src/widget/modules/state.ts b/packages/figma-widget/src/widget/modules/state.ts
index 12a394f0..b259f7e7 100644
--- a/packages/figma-widget/src/widget/modules/state.ts
+++ b/packages/figma-widget/src/widget/modules/state.ts
@@ -13,7 +13,7 @@ export const useSyncedLinkedProject = () => {
};
export const useSyncedLastSyncedAt = () => {
- return useSyncedState('lastSyncedAt', null);
+ return useSyncedState('lastSyncedAt', null);
};
export const useCleanupSyncedState = () => {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index c6fcb8b2..3ebec4c9 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -727,9 +727,15 @@ importers:
'@create-figma-plugin/utilities':
specifier: ^3.2.0
version: 3.2.0
+ '@date-fns/tz':
+ specifier: ^1.1.2
+ version: 1.1.2
'@tanstack/react-query':
specifier: ^5.51.24
version: 5.51.24(react@18.3.1)
+ date-fns:
+ specifier: ^3.6.0
+ version: 3.6.0
memoize:
specifier: ^10.0.0
version: 10.0.0
@@ -1633,6 +1639,9 @@ packages:
resolution: {integrity: sha512-+5JddDqI6XjVJs0EqgLd+6B9ukjhHFEBesqPI/e0okqS+Ay7Gt3xsD0vMrZjVYfJcmRAprgJhdGBGJZjOZiQIA==}
engines: {node: '>=20'}
+ '@date-fns/tz@1.1.2':
+ resolution: {integrity: sha512-Xmg2cPmOPQieCLAdf62KtFPU9y7wbQDq1OAzrs/bEQFvhtCPXDiks1CHDE/sTXReRfh/MICVkw/vY6OANHUGiA==}
+
'@dicebear/adventurer-neutral@9.2.2':
resolution: {integrity: sha512-XVAjhUWjav6luTZ7txz8zVJU/H0DiUy4uU1Z7IO5MDO6kWvum+If1+0OUgEWYZwM+RDI7rt2CgVP910DyZGd1w==}
engines: {node: '>=18.0.0'}
@@ -9566,6 +9575,8 @@ snapshots:
natural-compare-lite: 1.4.0
rgb-hex: 4.1.0
+ '@date-fns/tz@1.1.2': {}
+
'@dicebear/adventurer-neutral@9.2.2(@dicebear/core@9.2.2)':
dependencies:
'@dicebear/core': 9.2.2