diff --git a/e2e/specs/stateful/profile.spec.ts b/e2e/specs/stateful/profile.spec.ts index ef401983a..7013c915c 100644 --- a/e2e/specs/stateful/profile.spec.ts +++ b/e2e/specs/stateful/profile.spec.ts @@ -29,7 +29,7 @@ const profiles = [ { type: 'account', key: 'com.discord', - value: 'ens#0700', + value: 'nickjohnson', }, { type: 'account', diff --git a/package.json b/package.json index fe6a2c07c..60f20e9f2 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,7 @@ "@tanstack/query-sync-storage-persister": "4.29.1", "@tanstack/react-query": "4.29.1", "@tanstack/react-query-persist-client": "4.29.1", + "@types/luxon": "^3.3.1", "@wagmi/core": "0.10.11", "calendar-link": "^2.2.0", "dns-packet": "^5.4.0", @@ -94,6 +95,7 @@ "intl-segmenter-polyfill": "^0.4.4", "iso-639-1": "^2.1.15", "lodash": "^4.17.21", + "luxon": "^3.4.0", "markdown-to-jsx": "^7.1.7", "next": "12.1.6", "p-memoize": "^7.1.1", diff --git a/public/locales/en/register.json b/public/locales/en/register.json index 1f9de2574..49bc14578 100644 --- a/public/locales/en/register.json +++ b/public/locales/en/register.json @@ -67,8 +67,8 @@ "placeholder": { "com.twitter": "e.g. ensdomains", "com.github": "e.g. ensdomains", - "com.discord": "e.g. alisha.eth#0001", - "org.telegram": "e.g. futurealisha", + "com.discord": "e.g. nickjohnson", + "org.telegram": "e.g. nicksdjohnson", "email": "e.g. hello@example.com" } }, diff --git a/public/locales/en/transactionFlow.json b/public/locales/en/transactionFlow.json index dc16be42e..db1548035 100644 --- a/public/locales/en/transactionFlow.json +++ b/public/locales/en/transactionFlow.json @@ -53,10 +53,10 @@ "noOptions": "No account options available", "placeholder": { "default": "Add username here", - "com.twitter": "e.g. ensdomains", - "com.github": "e.g. ensdomains", - "com.discord": "e.g. alisha.eth#0001", - "org.telegram": "e.g. futurealisha", + "com.twitter": "e.g. nicksdjohnson", + "com.github": "e.g. arachnid", + "com.discord": "e.g. nickjohnson", + "org.telegram": "e.g. nicksdjohnson", "email": "e.g. hello@example.com" } }, diff --git a/public/locales/nl/transactionFlow.json b/public/locales/nl/transactionFlow.json index 9a7b2fafa..aae480c3f 100644 --- a/public/locales/nl/transactionFlow.json +++ b/public/locales/nl/transactionFlow.json @@ -54,7 +54,7 @@ "default": "Voeg username hier toe", "com.twitter": "e.g. ensdomains", "com.github": "e.g. ensdomains", - "com.discord": "e.g. alisha.eth#0001" + "com.discord": "e.g. nickjohnson" } }, "address": { diff --git a/public/locales/zh/register.json b/public/locales/zh/register.json index 80e9fb942..f91bbf5a5 100644 --- a/public/locales/zh/register.json +++ b/public/locales/zh/register.json @@ -63,9 +63,10 @@ "com.discord": "Discord" }, "placeholder": { - "com.twitter": "例如 ensdomains", - "com.github": "例如 ensdomains", - "com.discord": "例如 alisha.eth#0001" + "com.twitter": "例如 nicksdjohnson", + "com.github": "例如 arachnid", + "com.discord": "例如 nickjohnson", + "org.telegram": "e.g. nicksdjohnson" } }, "address": { diff --git a/public/locales/zh/transactionFlow.json b/public/locales/zh/transactionFlow.json index dd58e61d0..8d6ba3fda 100644 --- a/public/locales/zh/transactionFlow.json +++ b/public/locales/zh/transactionFlow.json @@ -53,9 +53,9 @@ "noOptions": "没有可用的账户", "placeholder": { "default": "在此添加用户名", - "com.twitter": "例如 ensdomains", - "com.github": "例如 ensdomains", - "com.discord": "例如 alisha.eth#0001" + "com.twitter": "例如 nicksdjohnson", + "com.github": "例如 arachnid", + "com.discord": "例如 nickjohnson" } }, "address": { diff --git a/src/assets/social/DynamicSocialIcon.tsx b/src/assets/social/DynamicSocialIcon.tsx index a50207d28..4c0ac7437 100644 --- a/src/assets/social/DynamicSocialIcon.tsx +++ b/src/assets/social/DynamicSocialIcon.tsx @@ -11,6 +11,7 @@ export const socialIconTypes = { 'com.twitter': dynamic(() => import('./SocialTwitter.svg')), 'com.youtube': dynamic(() => import('./SocialYoutube.svg')), 'org.telegram': dynamic(() => import('./SocialTelegram.svg')), + timezone: dynamic(() => import('@ensdomains/thorin').then((m) => m.MarkerSVG)), email: dynamic(() => import('@ensdomains/thorin').then((m) => m.EnvelopeSVG)), } @@ -22,6 +23,7 @@ export const socialIconColors = { 'com.twitter': '#65C5FC', 'com.youtube': '#FF0000', 'org.telegram': '#2BABEE', + timezone: '#000000', email: '#000000', } diff --git a/src/constants/supportedSocialRecordKeys.json b/src/constants/supportedSocialRecordKeys.json index 15452a1f9..abc8dba4d 100644 --- a/src/constants/supportedSocialRecordKeys.json +++ b/src/constants/supportedSocialRecordKeys.json @@ -1 +1 @@ -["com.twitter", "com.github", "com.discord", "org.telegram", "email"] +["com.twitter", "com.github", "com.discord", "org.telegram", "email", "timezone"] diff --git a/src/transaction-flow/input/AdvancedEditor/AdvancedEditor.test.tsx b/src/transaction-flow/input/AdvancedEditor/AdvancedEditor.test.tsx index caddcb705..ebbf8df1c 100644 --- a/src/transaction-flow/input/AdvancedEditor/AdvancedEditor.test.tsx +++ b/src/transaction-flow/input/AdvancedEditor/AdvancedEditor.test.tsx @@ -41,7 +41,7 @@ const mockProfileData = { { key: 'com.discord', type: 'text', - value: 'test#1234', + value: 'test', }, { key: 'com.reddit', diff --git a/src/transaction-flow/input/ProfileEditor/ProfileEditor.test.tsx b/src/transaction-flow/input/ProfileEditor/ProfileEditor.test.tsx index 17a554806..43f63b558 100644 --- a/src/transaction-flow/input/ProfileEditor/ProfileEditor.test.tsx +++ b/src/transaction-flow/input/ProfileEditor/ProfileEditor.test.tsx @@ -42,7 +42,7 @@ const mockProfileData = { { key: 'com.discord', type: 'text', - value: 'test#1234', + value: 'test', }, { key: 'com.reddit', diff --git a/src/utils/getSocialData.ts b/src/utils/getSocialData.ts index 4e9cf2a44..fb9334ae8 100644 --- a/src/utils/getSocialData.ts +++ b/src/utils/getSocialData.ts @@ -1,3 +1,5 @@ +import { DateTime } from 'luxon' + export const getSocialData = (iconKey: string, value: string) => { switch (iconKey) { case 'twitter': @@ -47,6 +49,34 @@ export const getSocialData = (iconKey: string, value: string) => { value, type: 'copy', } + case 'timezone': + return { + icon: 'timezone', + color: '#2BABEE', + label: 'Timezone', + value: (() => { + try { + const zone = DateTime.now().setZone(value) + const now = DateTime.now().toLocal() + + // Number of minutes between now and the target zone + const minutes = zone.offset - now.offset + const absoluteMinutes = Math.abs(minutes) + + // To hour offset, 120 minutes = "+2:00", 90 minutes = "+1:30" including leading zeroes + const offset = `${minutes < 0 ? '-' : '+'}${Math.floor(absoluteMinutes / 60) + .toString() + .padStart(2, '0')}:${Math.abs(absoluteMinutes % 60) + .toString() + .padStart(2, '0')}` + + return `${value} (${offset})` + } catch { + // If unable to parse offset simply return the user-set value + return value + } + })(), + } default: return null }