From a259121ab457b198331f7f412485639c702495ef Mon Sep 17 00:00:00 2001 From: gitstart-twenty Date: Fri, 18 Oct 2024 20:53:09 +0000 Subject: [PATCH] Migrate to twenty-ui - navigation/link --- .../sign-in-up/components/SignInUpForm.tsx | 3 +- .../components/AppNavigationDrawer.tsx | 16 +++- .../object-record/components/RecordChip.tsx | 3 +- .../RecordIndexOptionsDropdownContent.tsx | 2 +- .../RecordTableHeaderPlusButtonContent.tsx | 3 +- .../SettingsAccountsSettingsSection.tsx | 2 +- .../SettingsAccountsToggleSettingCard.tsx | 2 +- .../SettingsDataModelFieldToggle.tsx | 2 +- .../SettingsObjectNewFieldSelector.tsx | 3 +- ...IntegrationRemoteTableSyncStatusToggle.tsx | 2 +- ...tegrationDatabaseConnectionSummaryCard.tsx | 8 +- .../components/ToggleImpersonate.tsx | 2 +- .../ValidationStep/ValidationStep.tsx | 3 +- .../ValidationStep/components/columns.tsx | 3 +- .../field/display/components/EmailDisplay.tsx | 2 +- .../display/components/EmailsDisplay.tsx | 3 +- .../field/display/components/LinkDisplay.tsx | 7 +- .../field/display/components/LinksDisplay.tsx | 9 +- .../field/display/components/PhoneDisplay.tsx | 2 +- .../display/components/PhonesDisplay.tsx | 3 +- .../field/display/components/URLDisplay.tsx | 8 +- .../RightDrawerTopBarExpandButton.tsx | 3 +- .../menu-item/components/MenuItemToggle.tsx | 4 +- .../components/NavigationDrawerBackButton.tsx | 3 +- .../__stories__/NavigationDrawer.stories.tsx | 6 +- .../twenty-front/src/pages/auth/Authorize.tsx | 2 +- .../src/pages/not-found/NotFound.tsx | 2 +- .../src/pages/onboarding/ChooseYourPlan.tsx | 5 +- .../src/pages/onboarding/PaymentSuccess.tsx | 4 +- .../src/pages/onboarding/SyncEmails.tsx | 5 +- .../src/pages/settings/SettingsWorkspace.tsx | 7 +- .../SettingsObjectDetailPageContent.tsx | 3 +- .../settings/data-model/SettingsObjects.tsx | 9 +- .../SettingsServerlessFunctions.tsx | 3 +- .../getDisplayValueByUrlType.test.ts | 2 +- .../twenty-front/src/utils/checkUrlType.ts | 3 +- .../src/utils/getDisplayValueByUrlType.ts | 3 +- packages/twenty-front/tsup.ui.index.tsx | 12 +-- packages/twenty-ui/src/index.ts | 2 + .../src}/input/components/Toggle.tsx | 3 +- packages/twenty-ui/src/input/index.ts | 1 + packages/twenty-ui/src/navigation/index.ts | 10 +++ .../navigation/link/components/ActionLink.tsx | 0 .../components/AdvancedSettingsToggle.tsx | 19 +++-- .../link/components/ContactLink.tsx | 0 .../link/components/GithubVersionLink.tsx | 15 ++-- .../navigation/link/components/RawLink.tsx | 0 .../link/components/RoundedLink.tsx | 2 +- .../navigation/link/components/SocialLink.tsx | 3 +- .../link/components/UndecoratedLink.tsx | 0 .../__stories__/ActionLink.stories.tsx | 5 +- .../__stories__/ContactLink.stories.tsx | 3 +- .../__stories__/GithubVersionLink.stories.tsx | 3 +- .../__stories__/RawLink.stories.tsx | 3 +- .../__stories__/RoundedLink.stories.tsx | 3 +- .../__stories__/SocialLink.stories.tsx | 3 +- .../__stories__/UndecoratedLink.stories.tsx | 5 +- .../src/navigation/link/components/index.ts | 8 ++ .../src}/navigation/link/constants/Cal.ts | 0 .../navigation/link/constants/GithubLink.ts | 0 .../twenty-ui/src/navigation/link/index.ts | 3 + .../ComponentWithRouterDecorator.tsx | 82 +++++++++++++++++++ packages/twenty-ui/src/testing/index.ts | 1 + .../src/utilities/getDisplayValueByUrlType.ts | 34 ++++++++ packages/twenty-ui/src/utilities/index.ts | 1 + .../src/content/twenty-ui/input/toggle.mdx | 2 +- .../content/twenty-ui/navigation/links.mdx | 8 +- 67 files changed, 248 insertions(+), 135 deletions(-) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/input/components/Toggle.tsx (97%) create mode 100644 packages/twenty-ui/src/input/index.ts create mode 100644 packages/twenty-ui/src/navigation/index.ts rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/components/ActionLink.tsx (100%) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/components/AdvancedSettingsToggle.tsx (76%) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/components/ContactLink.tsx (100%) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/components/GithubVersionLink.tsx (51%) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/components/RawLink.tsx (100%) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/components/RoundedLink.tsx (96%) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/components/SocialLink.tsx (87%) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/components/UndecoratedLink.tsx (100%) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/components/__stories__/ActionLink.stories.tsx (82%) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/components/__stories__/ContactLink.stories.tsx (87%) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/components/__stories__/GithubVersionLink.stories.tsx (79%) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/components/__stories__/RawLink.stories.tsx (89%) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/components/__stories__/RoundedLink.stories.tsx (89%) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/components/__stories__/SocialLink.stories.tsx (91%) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/components/__stories__/UndecoratedLink.stories.tsx (79%) create mode 100644 packages/twenty-ui/src/navigation/link/components/index.ts rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/constants/Cal.ts (100%) rename packages/{twenty-front/src/modules/ui => twenty-ui/src}/navigation/link/constants/GithubLink.ts (100%) create mode 100644 packages/twenty-ui/src/navigation/link/index.ts create mode 100644 packages/twenty-ui/src/testing/decorators/ComponentWithRouterDecorator.tsx create mode 100644 packages/twenty-ui/src/utilities/getDisplayValueByUrlType.ts diff --git a/packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpForm.tsx b/packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpForm.tsx index 65021f7c6824..ff0622389e66 100644 --- a/packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpForm.tsx +++ b/packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpForm.tsx @@ -5,7 +5,7 @@ import { useMemo, useState } from 'react'; import { Controller } from 'react-hook-form'; import { useRecoilState, useRecoilValue } from 'recoil'; import { Key } from 'ts-key-enum'; -import { IconGoogle, IconMicrosoft } from 'twenty-ui'; +import { ActionLink, IconGoogle, IconMicrosoft } from 'twenty-ui'; import { FooterNote } from '@/auth/sign-in-up/components/FooterNote'; import { HorizontalSeparator } from '@/auth/sign-in-up/components/HorizontalSeparator'; @@ -24,7 +24,6 @@ import { captchaProviderState } from '@/client-config/states/captchaProviderStat import { Loader } from '@/ui/feedback/loader/components/Loader'; import { MainButton } from '@/ui/input/button/components/MainButton'; import { TextInput } from '@/ui/input/components/TextInput'; -import { ActionLink } from '@/ui/navigation/link/components/ActionLink'; import { isDefined } from '~/utils/isDefined'; const StyledContentContainer = styled.div` diff --git a/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx b/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx index 258473603420..29db273810cc 100644 --- a/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx +++ b/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx @@ -1,5 +1,5 @@ import { useEffect } from 'react'; -import { useRecoilValue, useSetRecoilState } from 'recoil'; +import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'; import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState'; import { SettingsNavigationDrawerItems } from '@/settings/components/SettingsNavigationDrawerItems'; @@ -8,14 +8,14 @@ import { NavigationDrawer, NavigationDrawerProps, } from '@/ui/navigation/navigation-drawer/components/NavigationDrawer'; - +import { isAdvancedModeEnabledState } from '@/ui/navigation/navigation-drawer/states/isAdvancedModeEnabledState'; import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile'; import { getImageAbsoluteURI } from '~/utils/image/getImageAbsoluteURI'; import { useIsSettingsDrawer } from '@/navigation/hooks/useIsSettingsDrawer'; -import { AdvancedSettingsToggle } from '@/ui/navigation/link/components/AdvancedSettingsToggle'; import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded'; +import { AdvancedSettingsToggle } from 'twenty-ui'; import { MainNavigationDrawerItems } from './MainNavigationDrawerItems'; export type AppNavigationDrawerProps = { @@ -31,12 +31,20 @@ export const AppNavigationDrawer = ({ isNavigationDrawerExpandedState, ); const currentWorkspace = useRecoilValue(currentWorkspaceState); + const [isAdvancedModeEnabled, setIsAdvancedModeEnabled] = useRecoilState( + isAdvancedModeEnabledState, + ); const drawerProps: NavigationDrawerProps = isSettingsDrawer ? { title: 'Exit Settings', children: , - footer: , + footer: ( + + ), } : { logo: diff --git a/packages/twenty-front/src/modules/object-record/components/RecordChip.tsx b/packages/twenty-front/src/modules/object-record/components/RecordChip.tsx index 16b207dbe12f..5e073040f46a 100644 --- a/packages/twenty-front/src/modules/object-record/components/RecordChip.tsx +++ b/packages/twenty-front/src/modules/object-record/components/RecordChip.tsx @@ -1,9 +1,8 @@ -import { AvatarChip, AvatarChipVariant } from 'twenty-ui'; +import { AvatarChip, AvatarChipVariant, UndecoratedLink } from 'twenty-ui'; import { getLinkToShowPage } from '@/object-metadata/utils/getLinkToShowPage'; import { useRecordChipData } from '@/object-record/hooks/useRecordChipData'; import { ObjectRecord } from '@/object-record/types/ObjectRecord'; -import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; import { MouseEvent } from 'react'; export type RecordChipProps = { diff --git a/packages/twenty-front/src/modules/object-record/record-index/options/components/RecordIndexOptionsDropdownContent.tsx b/packages/twenty-front/src/modules/object-record/record-index/options/components/RecordIndexOptionsDropdownContent.tsx index a884eda8582b..57362b722841 100644 --- a/packages/twenty-front/src/modules/object-record/record-index/options/components/RecordIndexOptionsDropdownContent.tsx +++ b/packages/twenty-front/src/modules/object-record/record-index/options/components/RecordIndexOptionsDropdownContent.tsx @@ -9,6 +9,7 @@ import { IconRotate2, IconSettings, IconTag, + UndecoratedLink, } from 'twenty-ui'; import { useObjectNamePluralFromSingular } from '@/object-metadata/hooks/useObjectNamePluralFromSingular'; @@ -28,7 +29,6 @@ import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenu import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; import { MenuItemNavigate } from '@/ui/navigation/menu-item/components/MenuItemNavigate'; import { MenuItemToggle } from '@/ui/navigation/menu-item/components/MenuItemToggle'; diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-header/components/RecordTableHeaderPlusButtonContent.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-header/components/RecordTableHeaderPlusButtonContent.tsx index f258a921383f..f5843543331d 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/record-table-header/components/RecordTableHeaderPlusButtonContent.tsx +++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-header/components/RecordTableHeaderPlusButtonContent.tsx @@ -1,7 +1,7 @@ import { useCallback, useContext } from 'react'; import { useLocation } from 'react-router-dom'; import { useRecoilValue, useSetRecoilState } from 'recoil'; -import { IconSettings, useIcons } from 'twenty-ui'; +import { IconSettings, UndecoratedLink, useIcons } from 'twenty-ui'; import { getObjectSlug } from '@/object-metadata/utils/getObjectSlug'; import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata'; @@ -12,7 +12,6 @@ import { ColumnDefinition } from '@/object-record/record-table/types/ColumnDefin import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; -import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState'; diff --git a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsSettingsSection.tsx b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsSettingsSection.tsx index 5da069e0b2ca..5c10785d1075 100644 --- a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsSettingsSection.tsx +++ b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsSettingsSection.tsx @@ -4,13 +4,13 @@ import { IconCalendarEvent, IconMailCog, MOBILE_VIEWPORT, + UndecoratedLink, } from 'twenty-ui'; import { SettingsCard } from '@/settings/components/SettingsCard'; import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath'; import { SettingsPath } from '@/types/SettingsPath'; import { Section } from '@/ui/layout/section/components/Section'; -import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; import { useTheme } from '@emotion/react'; const StyledCardsContainer = styled.div` diff --git a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsToggleSettingCard.tsx b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsToggleSettingCard.tsx index 62bfbaa40b8e..abe7548e9f9b 100644 --- a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsToggleSettingCard.tsx +++ b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsToggleSettingCard.tsx @@ -1,8 +1,8 @@ import styled from '@emotion/styled'; -import { Toggle } from '@/ui/input/components/Toggle'; import { Card } from '@/ui/layout/card/components/Card'; import { CardContent } from '@/ui/layout/card/components/CardContent'; +import { Toggle } from 'twenty-ui'; type Parameter = { value: boolean; diff --git a/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldToggle.tsx b/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldToggle.tsx index e859d652daca..5a994207300a 100644 --- a/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldToggle.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldToggle.tsx @@ -1,4 +1,3 @@ -import { Toggle } from '@/ui/input/components/Toggle'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; import { createPortal } from 'react-dom'; @@ -6,6 +5,7 @@ import { AppTooltip, IconComponent, IconInfoCircle, + Toggle, TooltipDelay, } from 'twenty-ui'; diff --git a/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsObjectNewFieldSelector.tsx b/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsObjectNewFieldSelector.tsx index 962fb7aaba5d..69644d6ab835 100644 --- a/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsObjectNewFieldSelector.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsObjectNewFieldSelector.tsx @@ -9,13 +9,12 @@ import { useCurrencySettingsFormInitialValues } from '@/settings/data-model/fiel import { useSelectSettingsFormInitialValues } from '@/settings/data-model/fields/forms/select/hooks/useSelectSettingsFormInitialValues'; import { SettingsFieldType } from '@/settings/data-model/types/SettingsFieldType'; import { TextInput } from '@/ui/input/components/TextInput'; -import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; import { Section } from '@react-email/components'; import { useState } from 'react'; import { Controller, useFormContext } from 'react-hook-form'; -import { H2Title, IconSearch } from 'twenty-ui'; +import { H2Title, IconSearch, UndecoratedLink } from 'twenty-ui'; import { FieldMetadataType } from '~/generated-metadata/graphql'; import { SettingsDataModelFieldTypeFormValues } from '~/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldSelect'; diff --git a/packages/twenty-front/src/modules/settings/integrations/components/SettingsIntegrationRemoteTableSyncStatusToggle.tsx b/packages/twenty-front/src/modules/settings/integrations/components/SettingsIntegrationRemoteTableSyncStatusToggle.tsx index f2d92a4ea1c7..88c9084cf86d 100644 --- a/packages/twenty-front/src/modules/settings/integrations/components/SettingsIntegrationRemoteTableSyncStatusToggle.tsx +++ b/packages/twenty-front/src/modules/settings/integrations/components/SettingsIntegrationRemoteTableSyncStatusToggle.tsx @@ -1,6 +1,6 @@ import { useState } from 'react'; +import { Toggle } from 'twenty-ui'; -import { Toggle } from '@/ui/input/components/Toggle'; import { RemoteTableStatus } from '~/generated-metadata/graphql'; export const SettingsIntegrationRemoteTableSyncStatusToggle = ({ diff --git a/packages/twenty-front/src/modules/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionSummaryCard.tsx b/packages/twenty-front/src/modules/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionSummaryCard.tsx index a29353d223da..ccc7dc0abb2c 100644 --- a/packages/twenty-front/src/modules/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionSummaryCard.tsx +++ b/packages/twenty-front/src/modules/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionSummaryCard.tsx @@ -1,5 +1,10 @@ import styled from '@emotion/styled'; -import { IconDotsVertical, IconPencil, IconTrash } from 'twenty-ui'; +import { + IconDotsVertical, + IconPencil, + IconTrash, + UndecoratedLink, +} from 'twenty-ui'; import { SettingsSummaryCard } from '@/settings/components/SettingsSummaryCard'; import { SettingsIntegrationDatabaseConnectionSyncStatus } from '@/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionSyncStatus'; @@ -7,7 +12,6 @@ import { LightIconButton } from '@/ui/input/button/components/LightIconButton'; import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu'; import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; -import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; type SettingsIntegrationDatabaseConnectionSummaryCardProps = { diff --git a/packages/twenty-front/src/modules/settings/workspace/components/ToggleImpersonate.tsx b/packages/twenty-front/src/modules/settings/workspace/components/ToggleImpersonate.tsx index 2b700540dd76..f38d318b375d 100644 --- a/packages/twenty-front/src/modules/settings/workspace/components/ToggleImpersonate.tsx +++ b/packages/twenty-front/src/modules/settings/workspace/components/ToggleImpersonate.tsx @@ -3,7 +3,7 @@ import { useRecoilState } from 'recoil'; import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState'; import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar'; import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar'; -import { Toggle } from '@/ui/input/components/Toggle'; +import { Toggle } from 'twenty-ui'; import { useUpdateWorkspaceMutation } from '~/generated/graphql'; export const ToggleImpersonate = () => { diff --git a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/ValidationStep/ValidationStep.tsx b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/ValidationStep/ValidationStep.tsx index 21b6d034923c..f74e6dcc742c 100644 --- a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/ValidationStep/ValidationStep.tsx +++ b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/ValidationStep/ValidationStep.tsx @@ -8,7 +8,7 @@ import { } from 'react'; // @ts-expect-error Todo: remove usage of react-data-grid` import { RowsChangeData } from 'react-data-grid'; -import { IconTrash } from 'twenty-ui'; +import { IconTrash, Toggle } from 'twenty-ui'; import { Heading } from '@/spreadsheet-import/components/Heading'; import { SpreadsheetImportTable } from '@/spreadsheet-import/components/SpreadsheetImportTable'; @@ -25,7 +25,6 @@ import { import { addErrorsAndRunHooks } from '@/spreadsheet-import/utils/dataMutations'; import { useDialogManager } from '@/ui/feedback/dialog-manager/hooks/useDialogManager'; import { Button } from '@/ui/input/button/components/Button'; -import { Toggle } from '@/ui/input/components/Toggle'; import { isDefined } from '~/utils/isDefined'; import { SpreadsheetImportStep } from '@/spreadsheet-import/steps/types/SpreadsheetImportStep'; diff --git a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/ValidationStep/components/columns.tsx b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/ValidationStep/components/columns.tsx index f2aa7983f410..de907c23f16e 100644 --- a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/ValidationStep/components/columns.tsx +++ b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/ValidationStep/components/columns.tsx @@ -2,13 +2,12 @@ import styled from '@emotion/styled'; // @ts-expect-error // Todo: remove usage of react-data-grid import { Column, useRowSelection } from 'react-data-grid'; import { createPortal } from 'react-dom'; -import { AppTooltip } from 'twenty-ui'; +import { AppTooltip, Toggle } from 'twenty-ui'; import { MatchColumnSelect } from '@/spreadsheet-import/components/MatchColumnSelect'; import { Fields, ImportedStructuredRow } from '@/spreadsheet-import/types'; import { Checkbox, CheckboxVariant } from '@/ui/input/components/Checkbox'; import { TextInput } from '@/ui/input/components/TextInput'; -import { Toggle } from '@/ui/input/components/Toggle'; import { isDefined } from '~/utils/isDefined'; import { ImportedStructuredRowMetadata } from '../types'; diff --git a/packages/twenty-front/src/modules/ui/field/display/components/EmailDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/EmailDisplay.tsx index 2fe096c17628..75089eaf6f16 100644 --- a/packages/twenty-front/src/modules/ui/field/display/components/EmailDisplay.tsx +++ b/packages/twenty-front/src/modules/ui/field/display/components/EmailDisplay.tsx @@ -1,8 +1,8 @@ import { MouseEvent } from 'react'; -import { ContactLink } from '@/ui/navigation/link/components/ContactLink'; import { isDefined } from '~/utils/isDefined'; +import { ContactLink } from 'twenty-ui'; import { EllipsisDisplay } from './EllipsisDisplay'; const validateEmail = (email: string) => { diff --git a/packages/twenty-front/src/modules/ui/field/display/components/EmailsDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/EmailsDisplay.tsx index 8b7e67780a2a..e2737dadce15 100644 --- a/packages/twenty-front/src/modules/ui/field/display/components/EmailsDisplay.tsx +++ b/packages/twenty-front/src/modules/ui/field/display/components/EmailsDisplay.tsx @@ -1,9 +1,8 @@ import { useMemo } from 'react'; -import { THEME_COMMON } from 'twenty-ui'; +import { RoundedLink, THEME_COMMON } from 'twenty-ui'; import { FieldEmailsValue } from '@/object-record/record-field/types/FieldMetadata'; import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList'; -import { RoundedLink } from '@/ui/navigation/link/components/RoundedLink'; import styled from '@emotion/styled'; import { isDefined } from '~/utils/isDefined'; diff --git a/packages/twenty-front/src/modules/ui/field/display/components/LinkDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/LinkDisplay.tsx index 963887f11e0d..f5cef6d9d12f 100644 --- a/packages/twenty-front/src/modules/ui/field/display/components/LinkDisplay.tsx +++ b/packages/twenty-front/src/modules/ui/field/display/components/LinkDisplay.tsx @@ -1,10 +1,5 @@ import { isNonEmptyString } from '@sniptt/guards'; - -import { RoundedLink } from '@/ui/navigation/link/components/RoundedLink'; -import { - LinkType, - SocialLink, -} from '@/ui/navigation/link/components/SocialLink'; +import { LinkType, RoundedLink, SocialLink } from 'twenty-ui'; type LinkDisplayProps = { value?: { url: string; label?: string }; diff --git a/packages/twenty-front/src/modules/ui/field/display/components/LinksDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/LinksDisplay.tsx index 339859dfe62a..8b4b52a63ba7 100644 --- a/packages/twenty-front/src/modules/ui/field/display/components/LinksDisplay.tsx +++ b/packages/twenty-front/src/modules/ui/field/display/components/LinksDisplay.tsx @@ -1,14 +1,9 @@ -import { useMemo } from 'react'; import { styled } from '@linaria/react'; -import { THEME_COMMON } from 'twenty-ui'; +import { useMemo } from 'react'; +import { LinkType, RoundedLink, SocialLink, THEME_COMMON } from 'twenty-ui'; import { FieldLinksValue } from '@/object-record/record-field/types/FieldMetadata'; import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList'; -import { RoundedLink } from '@/ui/navigation/link/components/RoundedLink'; -import { - LinkType, - SocialLink, -} from '@/ui/navigation/link/components/SocialLink'; import { checkUrlType } from '~/utils/checkUrlType'; import { isDefined } from '~/utils/isDefined'; import { getAbsoluteUrl } from '~/utils/url/getAbsoluteUrl'; diff --git a/packages/twenty-front/src/modules/ui/field/display/components/PhoneDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/PhoneDisplay.tsx index 7c79ac85e7f6..02c518278fbb 100644 --- a/packages/twenty-front/src/modules/ui/field/display/components/PhoneDisplay.tsx +++ b/packages/twenty-front/src/modules/ui/field/display/components/PhoneDisplay.tsx @@ -1,7 +1,7 @@ import { parsePhoneNumber, PhoneNumber } from 'libphonenumber-js'; import { MouseEvent } from 'react'; +import { ContactLink } from 'twenty-ui'; -import { ContactLink } from '@/ui/navigation/link/components/ContactLink'; import { isDefined } from '~/utils/isDefined'; type PhoneDisplayProps = { diff --git a/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx index deee867fc16e..6dbca8829d90 100644 --- a/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx +++ b/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx @@ -1,10 +1,9 @@ import styled from '@emotion/styled'; import { useMemo } from 'react'; -import { THEME_COMMON } from 'twenty-ui'; +import { RoundedLink, THEME_COMMON } from 'twenty-ui'; import { FieldPhonesValue } from '@/object-record/record-field/types/FieldMetadata'; import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList'; -import { RoundedLink } from '@/ui/navigation/link/components/RoundedLink'; import { parsePhoneNumber } from 'libphonenumber-js'; import { isDefined } from '~/utils/isDefined'; diff --git a/packages/twenty-front/src/modules/ui/field/display/components/URLDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/URLDisplay.tsx index 561b1d0dd319..976ba1c0800b 100644 --- a/packages/twenty-front/src/modules/ui/field/display/components/URLDisplay.tsx +++ b/packages/twenty-front/src/modules/ui/field/display/components/URLDisplay.tsx @@ -1,13 +1,9 @@ -import { MouseEvent } from 'react'; import styled from '@emotion/styled'; +import { MouseEvent } from 'react'; -import { RoundedLink } from '@/ui/navigation/link/components/RoundedLink'; -import { - LinkType, - SocialLink, -} from '@/ui/navigation/link/components/SocialLink'; import { checkUrlType } from '~/utils/checkUrlType'; +import { LinkType, RoundedLink, SocialLink } from 'twenty-ui'; import { EllipsisDisplay } from './EllipsisDisplay'; const StyledRawLink = styled(RoundedLink)` diff --git a/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawerTopBarExpandButton.tsx b/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawerTopBarExpandButton.tsx index f3d187a9400a..a0b96b0501a4 100644 --- a/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawerTopBarExpandButton.tsx +++ b/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawerTopBarExpandButton.tsx @@ -1,7 +1,6 @@ import { LightIconButton } from '@/ui/input/button/components/LightIconButton'; import { useRightDrawer } from '@/ui/layout/right-drawer/hooks/useRightDrawer'; -import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; -import { IconExternalLink } from 'twenty-ui'; +import { IconExternalLink, UndecoratedLink } from 'twenty-ui'; export const RightDrawerTopBarExpandButton = ({ to }: { to: string }) => { const { closeRightDrawer } = useRightDrawer(); diff --git a/packages/twenty-front/src/modules/ui/navigation/menu-item/components/MenuItemToggle.tsx b/packages/twenty-front/src/modules/ui/navigation/menu-item/components/MenuItemToggle.tsx index 2692c65773a2..256c038e8a14 100644 --- a/packages/twenty-front/src/modules/ui/navigation/menu-item/components/MenuItemToggle.tsx +++ b/packages/twenty-front/src/modules/ui/navigation/menu-item/components/MenuItemToggle.tsx @@ -1,6 +1,4 @@ -import { IconComponent } from 'twenty-ui'; - -import { Toggle, ToggleSize } from '@/ui/input/components/Toggle'; +import { IconComponent, Toggle, ToggleSize } from 'twenty-ui'; import { MenuItemLeftContent } from '../internals/components/MenuItemLeftContent'; import { diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerBackButton.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerBackButton.tsx index 486027966164..ec0c5bcfe061 100644 --- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerBackButton.tsx +++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerBackButton.tsx @@ -1,9 +1,8 @@ import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; import { useRecoilValue, useSetRecoilState } from 'recoil'; -import { IconX } from 'twenty-ui'; +import { IconX, UndecoratedLink } from 'twenty-ui'; -import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded'; import { navigationDrawerExpandedMemorizedState } from '@/ui/navigation/states/navigationDrawerExpandedMemorizedState'; import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState'; diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawer.stories.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawer.stories.tsx index 1fe45b7822ac..93db01f85838 100644 --- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawer.stories.tsx +++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawer.stories.tsx @@ -1,5 +1,6 @@ import { Meta, StoryObj } from '@storybook/react'; import { + GithubVersionLink, IconAt, IconBell, IconBuildingSkyscraper, @@ -18,18 +19,17 @@ import { import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath'; import { SettingsPath } from '@/types/SettingsPath'; -import { GithubVersionLink } from '@/ui/navigation/link/components/GithubVersionLink'; import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator'; import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator'; import { CurrentWorkspaceMemberFavorites } from '@/favorites/components/CurrentWorkspaceMemberFavorites'; import { NavigationDrawerSubItem } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSubItem'; +import jsonPage from '../../../../../../../package.json'; import { NavigationDrawer } from '../NavigationDrawer'; import { NavigationDrawerItem } from '../NavigationDrawerItem'; import { NavigationDrawerItemGroup } from '../NavigationDrawerItemGroup'; import { NavigationDrawerSection } from '../NavigationDrawerSection'; import { NavigationDrawerSectionTitle } from '../NavigationDrawerSectionTitle'; - const meta: Meta = { title: 'UI/Navigation/NavigationDrawer/NavigationDrawer', component: NavigationDrawer, @@ -148,6 +148,6 @@ export const Settings: Story = { ), - footer: , + footer: , }, }; diff --git a/packages/twenty-front/src/pages/auth/Authorize.tsx b/packages/twenty-front/src/pages/auth/Authorize.tsx index 20be8c5017a0..b97c31815dfe 100644 --- a/packages/twenty-front/src/pages/auth/Authorize.tsx +++ b/packages/twenty-front/src/pages/auth/Authorize.tsx @@ -4,7 +4,7 @@ import { useNavigate, useSearchParams } from 'react-router-dom'; import { AppPath } from '@/types/AppPath'; import { MainButton } from '@/ui/input/button/components/MainButton'; -import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; +import { UndecoratedLink } from 'twenty-ui'; import { useAuthorizeAppMutation } from '~/generated/graphql'; import { isDefined } from '~/utils/isDefined'; diff --git a/packages/twenty-front/src/pages/not-found/NotFound.tsx b/packages/twenty-front/src/pages/not-found/NotFound.tsx index bf3acc27aed8..28ea97c0832c 100644 --- a/packages/twenty-front/src/pages/not-found/NotFound.tsx +++ b/packages/twenty-front/src/pages/not-found/NotFound.tsx @@ -10,8 +10,8 @@ import { AnimatedPlaceholderErrorSubTitle, AnimatedPlaceholderErrorTitle, } from '@/ui/layout/animated-placeholder/components/ErrorPlaceholderStyled'; -import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; import { PageTitle } from '@/ui/utilities/page-title/PageTitle'; +import { UndecoratedLink } from 'twenty-ui'; const StyledBackDrop = styled.div` align-items: center; diff --git a/packages/twenty-front/src/pages/onboarding/ChooseYourPlan.tsx b/packages/twenty-front/src/pages/onboarding/ChooseYourPlan.tsx index 02fc25fbb992..d9e934e57c01 100644 --- a/packages/twenty-front/src/pages/onboarding/ChooseYourPlan.tsx +++ b/packages/twenty-front/src/pages/onboarding/ChooseYourPlan.tsx @@ -1,6 +1,6 @@ -import React, { useState } from 'react'; import styled from '@emotion/styled'; import { isNonEmptyString, isNumber } from '@sniptt/guards'; +import { useState } from 'react'; import { useRecoilValue } from 'recoil'; import { SubTitle } from '@/auth/components/SubTitle'; @@ -15,8 +15,7 @@ import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/Snac import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar'; import { MainButton } from '@/ui/input/button/components/MainButton'; import { CardPicker } from '@/ui/input/components/CardPicker'; -import { ActionLink } from '@/ui/navigation/link/components/ActionLink'; -import { CAL_LINK } from '@/ui/navigation/link/constants/Cal'; +import { ActionLink, CAL_LINK } from 'twenty-ui'; import { ProductPriceEntity, SubscriptionInterval, diff --git a/packages/twenty-front/src/pages/onboarding/PaymentSuccess.tsx b/packages/twenty-front/src/pages/onboarding/PaymentSuccess.tsx index ce57c50795ad..f0e3c02d8ff8 100644 --- a/packages/twenty-front/src/pages/onboarding/PaymentSuccess.tsx +++ b/packages/twenty-front/src/pages/onboarding/PaymentSuccess.tsx @@ -1,15 +1,13 @@ -import React from 'react'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; import { useRecoilValue } from 'recoil'; -import { IconCheck, RGBA } from 'twenty-ui'; +import { IconCheck, RGBA, UndecoratedLink } from 'twenty-ui'; import { SubTitle } from '@/auth/components/SubTitle'; import { Title } from '@/auth/components/Title'; import { currentUserState } from '@/auth/states/currentUserState'; import { AppPath } from '@/types/AppPath'; import { MainButton } from '@/ui/input/button/components/MainButton'; -import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; import { AnimatedEaseIn } from '@/ui/utilities/animation/components/AnimatedEaseIn'; import { OnboardingStatus } from '~/generated/graphql'; diff --git a/packages/twenty-front/src/pages/onboarding/SyncEmails.tsx b/packages/twenty-front/src/pages/onboarding/SyncEmails.tsx index c80eed892c75..259f519e4e78 100644 --- a/packages/twenty-front/src/pages/onboarding/SyncEmails.tsx +++ b/packages/twenty-front/src/pages/onboarding/SyncEmails.tsx @@ -1,9 +1,9 @@ -import React, { useState } from 'react'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; +import { useState } from 'react'; import { useRecoilValue } from 'recoil'; import { Key } from 'ts-key-enum'; -import { IconGoogle } from 'twenty-ui'; +import { ActionLink, IconGoogle } from 'twenty-ui'; import { SubTitle } from '@/auth/components/SubTitle'; import { Title } from '@/auth/components/Title'; @@ -14,7 +14,6 @@ import { useTriggerGoogleApisOAuth } from '@/settings/accounts/hooks/useTriggerG import { AppPath } from '@/types/AppPath'; import { PageHotkeyScope } from '@/types/PageHotkeyScope'; import { MainButton } from '@/ui/input/button/components/MainButton'; -import { ActionLink } from '@/ui/navigation/link/components/ActionLink'; import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys'; import { CalendarChannelVisibility, diff --git a/packages/twenty-front/src/pages/settings/SettingsWorkspace.tsx b/packages/twenty-front/src/pages/settings/SettingsWorkspace.tsx index 329c736f1834..e9b4fed6bfc6 100644 --- a/packages/twenty-front/src/pages/settings/SettingsWorkspace.tsx +++ b/packages/twenty-front/src/pages/settings/SettingsWorkspace.tsx @@ -1,4 +1,4 @@ -import { H2Title } from 'twenty-ui'; +import { GithubVersionLink, H2Title } from 'twenty-ui'; import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer'; import { DeleteWorkspace } from '@/settings/profile/components/DeleteWorkspace'; @@ -9,8 +9,7 @@ import { WorkspaceLogoUploader } from '@/settings/workspace/components/Workspace import { SettingsPath } from '@/types/SettingsPath'; import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer'; import { Section } from '@/ui/layout/section/components/Section'; -import { GithubVersionLink } from '@/ui/navigation/link/components/GithubVersionLink'; - +import packageJson from '../../../package.json'; export const SettingsWorkspace = () => ( (
- +
diff --git a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectDetailPageContent.tsx b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectDetailPageContent.tsx index 37fb2d9c0cd2..eebb1ace9761 100644 --- a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectDetailPageContent.tsx +++ b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectDetailPageContent.tsx @@ -7,13 +7,12 @@ import { SettingsPath } from '@/types/SettingsPath'; import { Button } from '@/ui/input/button/components/Button'; import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer'; import { Section } from '@/ui/layout/section/components/Section'; -import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; import { isAdvancedModeEnabledState } from '@/ui/navigation/navigation-drawer/states/isAdvancedModeEnabledState'; import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; import styled from '@emotion/styled'; import { useNavigate } from 'react-router-dom'; import { useRecoilValue } from 'recoil'; -import { H2Title, IconPlus } from 'twenty-ui'; +import { H2Title, IconPlus, UndecoratedLink } from 'twenty-ui'; import { SettingsObjectFieldTable } from '~/pages/settings/data-model/SettingsObjectFieldTable'; import { SettingsObjectIndexTable } from '~/pages/settings/data-model/SettingsObjectIndexTable'; diff --git a/packages/twenty-front/src/pages/settings/data-model/SettingsObjects.tsx b/packages/twenty-front/src/pages/settings/data-model/SettingsObjects.tsx index 7c7e280569d7..16044299b581 100644 --- a/packages/twenty-front/src/pages/settings/data-model/SettingsObjects.tsx +++ b/packages/twenty-front/src/pages/settings/data-model/SettingsObjects.tsx @@ -1,6 +1,12 @@ import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; -import { H2Title, IconChevronRight, IconPlus, IconSearch } from 'twenty-ui'; +import { + H2Title, + IconChevronRight, + IconPlus, + IconSearch, + UndecoratedLink, +} from 'twenty-ui'; import { useDeleteOneObjectMetadataItem } from '@/object-metadata/hooks/useDeleteOneObjectMetadataItem'; import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems'; @@ -26,7 +32,6 @@ import { Table } from '@/ui/layout/table/components/Table'; import { TableHeader } from '@/ui/layout/table/components/TableHeader'; import { TableSection } from '@/ui/layout/table/components/TableSection'; import { useSortedArray } from '@/ui/layout/table/hooks/useSortedArray'; -import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; import { isNonEmptyArray } from '@sniptt/guards'; import { useMemo, useState } from 'react'; import { SETTINGS_OBJECT_TABLE_METADATA } from '~/pages/settings/data-model/constants/SettingsObjectTableMetadata'; diff --git a/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctions.tsx b/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctions.tsx index 9cfd9b04ca42..2344ae651a60 100644 --- a/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctions.tsx +++ b/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctions.tsx @@ -4,8 +4,7 @@ import { SettingsPath } from '@/types/SettingsPath'; import { Button } from '@/ui/input/button/components/Button'; import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer'; import { Section } from '@/ui/layout/section/components/Section'; -import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; -import { IconPlus } from 'twenty-ui'; +import { IconPlus, UndecoratedLink } from 'twenty-ui'; export const SettingsServerlessFunctions = () => { return ( diff --git a/packages/twenty-front/src/utils/__tests__/getDisplayValueByUrlType.test.ts b/packages/twenty-front/src/utils/__tests__/getDisplayValueByUrlType.test.ts index 58f447bec1a9..aff9792f5676 100644 --- a/packages/twenty-front/src/utils/__tests__/getDisplayValueByUrlType.test.ts +++ b/packages/twenty-front/src/utils/__tests__/getDisplayValueByUrlType.test.ts @@ -1,4 +1,4 @@ -import { LinkType } from '@/ui/navigation/link/components/SocialLink'; +import { LinkType } from 'twenty-ui'; import { getDisplayValueByUrlType } from '~/utils/getDisplayValueByUrlType'; describe('getDisplayValueByUrlType', () => { diff --git a/packages/twenty-front/src/utils/checkUrlType.ts b/packages/twenty-front/src/utils/checkUrlType.ts index 13f1499c2082..a806478b9b3d 100644 --- a/packages/twenty-front/src/utils/checkUrlType.ts +++ b/packages/twenty-front/src/utils/checkUrlType.ts @@ -1,5 +1,4 @@ -import { LinkType } from '@/ui/navigation/link/components/SocialLink'; - +import { LinkType } from 'twenty-ui'; import { isDefined } from './isDefined'; export const checkUrlType = (url: string) => { diff --git a/packages/twenty-front/src/utils/getDisplayValueByUrlType.ts b/packages/twenty-front/src/utils/getDisplayValueByUrlType.ts index 5e5087d5c0ba..cc1accb5685a 100644 --- a/packages/twenty-front/src/utils/getDisplayValueByUrlType.ts +++ b/packages/twenty-front/src/utils/getDisplayValueByUrlType.ts @@ -1,5 +1,4 @@ -import { LinkType } from '@/ui/navigation/link/components/SocialLink'; - +import { LinkType } from 'twenty-ui'; import { isDefined } from './isDefined'; type getUrlDisplayValueByUrlTypeProps = { diff --git a/packages/twenty-front/tsup.ui.index.tsx b/packages/twenty-front/tsup.ui.index.tsx index edb0ae481f5e..bf82bb0c785c 100644 --- a/packages/twenty-front/tsup.ui.index.tsx +++ b/packages/twenty-front/tsup.ui.index.tsx @@ -8,8 +8,8 @@ declare module '@emotion/react' { } export * from 'twenty-ui'; -export * from './src/modules/ui/feedback/progress-bar/components/ProgressBar'; export * from './src/modules/ui/feedback/progress-bar/components/CircularProgressBar'; +export * from './src/modules/ui/feedback/progress-bar/components/ProgressBar'; export * from './src/modules/ui/input/button/components/Button'; export * from './src/modules/ui/input/button/components/ButtonGroup'; export * from './src/modules/ui/input/button/components/FloatingButton'; @@ -17,7 +17,6 @@ export * from './src/modules/ui/input/button/components/FloatingButtonGroup'; export * from './src/modules/ui/input/button/components/FloatingIconButton'; export * from './src/modules/ui/input/button/components/FloatingIconButtonGroup'; export * from './src/modules/ui/input/button/components/LightButton'; -export * from './src/modules/ui/navigation/link/components/ActionLink'; export * from './src/modules/ui/input/button/components/LightIconButton'; export * from './src/modules/ui/input/button/components/MainButton'; export * from './src/modules/ui/input/button/components/RoundedIconButton'; @@ -30,16 +29,11 @@ export * from './src/modules/ui/input/components/IconPicker'; export * from './src/modules/ui/input/components/ImageInput'; export * from './src/modules/ui/input/components/Radio'; export * from './src/modules/ui/input/components/RadioGroup'; -export * from './src/modules/ui/input/button/components/Button'; export * from './src/modules/ui/input/components/Select'; export * from './src/modules/ui/input/components/TextArea'; export * from './src/modules/ui/input/components/TextInput'; -export * from './src/modules/ui/input/components/Toggle'; export * from './src/modules/ui/input/editor/components/BlockEditor'; -export * from './src/modules/ui/navigation/link/components/ContactLink'; -export * from './src/modules/ui/navigation/link/components/RawLink'; -export * from './src/modules/ui/navigation/link/components/RoundedLink'; -export * from './src/modules/ui/navigation/link/components/SocialLink'; +export * from './src/modules/ui/navigation/bread-crumb/components/Breadcrumb'; export * from './src/modules/ui/navigation/menu-item/components/MenuItem'; export * from './src/modules/ui/navigation/menu-item/components/MenuItemCommand'; export * from './src/modules/ui/navigation/menu-item/components/MenuItemDraggable'; @@ -50,6 +44,6 @@ export * from './src/modules/ui/navigation/menu-item/components/MenuItemSelect'; export * from './src/modules/ui/navigation/menu-item/components/MenuItemSelectAvatar'; export * from './src/modules/ui/navigation/menu-item/components/MenuItemSelectColor'; export * from './src/modules/ui/navigation/menu-item/components/MenuItemToggle'; -export * from './src/modules/ui/navigation/bread-crumb/components/Breadcrumb'; export * from './src/modules/ui/navigation/navigation-bar/components/NavigationBar'; export * from './src/modules/ui/navigation/step-bar/components/StepBar'; + diff --git a/packages/twenty-ui/src/index.ts b/packages/twenty-ui/src/index.ts index bc26e1a7c694..738d8f7b85cf 100644 --- a/packages/twenty-ui/src/index.ts +++ b/packages/twenty-ui/src/index.ts @@ -1,6 +1,8 @@ export * from './components'; export * from './display'; +export * from './input'; export * from './layout'; +export * from './navigation'; export * from './testing'; export * from './theme'; export * from './utilities'; diff --git a/packages/twenty-front/src/modules/ui/input/components/Toggle.tsx b/packages/twenty-ui/src/input/components/Toggle.tsx similarity index 97% rename from packages/twenty-front/src/modules/ui/input/components/Toggle.tsx rename to packages/twenty-ui/src/input/components/Toggle.tsx index 39bafac99582..ccb0aae2cb11 100644 --- a/packages/twenty-front/src/modules/ui/input/components/Toggle.tsx +++ b/packages/twenty-ui/src/input/components/Toggle.tsx @@ -1,9 +1,8 @@ import styled from '@emotion/styled'; +import { isDefined } from '@ui/utilities'; import { motion } from 'framer-motion'; import { useEffect, useState } from 'react'; -import { isDefined } from '~/utils/isDefined'; - export type ToggleSize = 'small' | 'medium'; type ContainerProps = { diff --git a/packages/twenty-ui/src/input/index.ts b/packages/twenty-ui/src/input/index.ts new file mode 100644 index 000000000000..133f827052db --- /dev/null +++ b/packages/twenty-ui/src/input/index.ts @@ -0,0 +1 @@ +export * from './components/Toggle'; diff --git a/packages/twenty-ui/src/navigation/index.ts b/packages/twenty-ui/src/navigation/index.ts new file mode 100644 index 000000000000..f5f3f6fd7238 --- /dev/null +++ b/packages/twenty-ui/src/navigation/index.ts @@ -0,0 +1,10 @@ +export * from './link/components/ActionLink'; +export * from './link/components/AdvancedSettingsToggle'; +export * from './link/components/ContactLink'; +export * from './link/components/GithubVersionLink'; +export * from './link/components/RawLink'; +export * from './link/components/RoundedLink'; +export * from './link/components/SocialLink'; +export * from './link/components/UndecoratedLink'; +export * from './link/constants/Cal'; +export * from './link/constants/GithubLink'; diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/ActionLink.tsx b/packages/twenty-ui/src/navigation/link/components/ActionLink.tsx similarity index 100% rename from packages/twenty-front/src/modules/ui/navigation/link/components/ActionLink.tsx rename to packages/twenty-ui/src/navigation/link/components/ActionLink.tsx diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/AdvancedSettingsToggle.tsx b/packages/twenty-ui/src/navigation/link/components/AdvancedSettingsToggle.tsx similarity index 76% rename from packages/twenty-front/src/modules/ui/navigation/link/components/AdvancedSettingsToggle.tsx rename to packages/twenty-ui/src/navigation/link/components/AdvancedSettingsToggle.tsx index e08f60031bf1..6c472f5912a2 100644 --- a/packages/twenty-front/src/modules/ui/navigation/link/components/AdvancedSettingsToggle.tsx +++ b/packages/twenty-ui/src/navigation/link/components/AdvancedSettingsToggle.tsx @@ -1,8 +1,7 @@ -import { Toggle } from '@/ui/input/components/Toggle'; -import { isAdvancedModeEnabledState } from '@/ui/navigation/navigation-drawer/states/isAdvancedModeEnabledState'; import styled from '@emotion/styled'; -import { useRecoilState } from 'recoil'; -import { IconTool, MAIN_COLORS } from 'twenty-ui'; +import { IconTool } from '@ui/display'; +import { Toggle } from '@ui/input'; +import { MAIN_COLORS } from '@ui/theme'; const StyledContainer = styled.div` align-items: center; @@ -37,11 +36,15 @@ const StyledIconTool = styled(IconTool)` margin-right: ${({ theme }) => theme.spacing(0.5)}; `; -export const AdvancedSettingsToggle = () => { - const [isAdvancedModeEnabled, setIsAdvancedModeEnabled] = useRecoilState( - isAdvancedModeEnabledState, - ); +interface AdvancedSettingsToggleProps { + isAdvancedModeEnabled: boolean; + setIsAdvancedModeEnabled: (enabled: boolean) => void; +} +export const AdvancedSettingsToggle = ({ + isAdvancedModeEnabled, + setIsAdvancedModeEnabled, +}: AdvancedSettingsToggleProps) => { const onChange = (newValue: boolean) => { setIsAdvancedModeEnabled(newValue); }; diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/ContactLink.tsx b/packages/twenty-ui/src/navigation/link/components/ContactLink.tsx similarity index 100% rename from packages/twenty-front/src/modules/ui/navigation/link/components/ContactLink.tsx rename to packages/twenty-ui/src/navigation/link/components/ContactLink.tsx diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/GithubVersionLink.tsx b/packages/twenty-ui/src/navigation/link/components/GithubVersionLink.tsx similarity index 51% rename from packages/twenty-front/src/modules/ui/navigation/link/components/GithubVersionLink.tsx rename to packages/twenty-ui/src/navigation/link/components/GithubVersionLink.tsx index 0d2ed27331cc..10e4534d6ea4 100644 --- a/packages/twenty-front/src/modules/ui/navigation/link/components/GithubVersionLink.tsx +++ b/packages/twenty-ui/src/navigation/link/components/GithubVersionLink.tsx @@ -1,18 +1,19 @@ import { useTheme } from '@emotion/react'; -import { IconBrandGithub } from 'twenty-ui'; - -import { ActionLink } from '@/ui/navigation/link/components/ActionLink'; - -import packageJson from '../../../../../../package.json'; +import { IconBrandGithub } from '@ui/display'; +import { ActionLink } from '@ui/navigation/link/components/ActionLink'; import { GITHUB_LINK } from '../constants/GithubLink'; -export const GithubVersionLink = () => { +interface GithubVersionLinkProps { + version: string; +} + +export const GithubVersionLink = ({ version }: GithubVersionLinkProps) => { const theme = useTheme(); return ( - {packageJson.version} + {version} ); }; diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/RawLink.tsx b/packages/twenty-ui/src/navigation/link/components/RawLink.tsx similarity index 100% rename from packages/twenty-front/src/modules/ui/navigation/link/components/RawLink.tsx rename to packages/twenty-ui/src/navigation/link/components/RawLink.tsx diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink.tsx b/packages/twenty-ui/src/navigation/link/components/RoundedLink.tsx similarity index 96% rename from packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink.tsx rename to packages/twenty-ui/src/navigation/link/components/RoundedLink.tsx index 4db0e8dd2c4f..ef3b05953ec2 100644 --- a/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink.tsx +++ b/packages/twenty-ui/src/navigation/link/components/RoundedLink.tsx @@ -1,7 +1,7 @@ import { styled } from '@linaria/react'; import { isNonEmptyString } from '@sniptt/guards'; +import { FONT_COMMON, THEME_COMMON, ThemeContext } from '@ui/theme'; import { MouseEvent, useContext } from 'react'; -import { FONT_COMMON, THEME_COMMON, ThemeContext } from 'twenty-ui'; type RoundedLinkProps = { href: string; diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/SocialLink.tsx b/packages/twenty-ui/src/navigation/link/components/SocialLink.tsx similarity index 87% rename from packages/twenty-front/src/modules/ui/navigation/link/components/SocialLink.tsx rename to packages/twenty-ui/src/navigation/link/components/SocialLink.tsx index aa98b456917f..a5b756e30b00 100644 --- a/packages/twenty-front/src/modules/ui/navigation/link/components/SocialLink.tsx +++ b/packages/twenty-ui/src/navigation/link/components/SocialLink.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; -import { getDisplayValueByUrlType } from '~/utils/getDisplayValueByUrlType'; - +import { getDisplayValueByUrlType } from '@ui/utilities'; import { RoundedLink } from './RoundedLink'; export enum LinkType { diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/UndecoratedLink.tsx b/packages/twenty-ui/src/navigation/link/components/UndecoratedLink.tsx similarity index 100% rename from packages/twenty-front/src/modules/ui/navigation/link/components/UndecoratedLink.tsx rename to packages/twenty-ui/src/navigation/link/components/UndecoratedLink.tsx diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/ActionLink.stories.tsx b/packages/twenty-ui/src/navigation/link/components/__stories__/ActionLink.stories.tsx similarity index 82% rename from packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/ActionLink.stories.tsx rename to packages/twenty-ui/src/navigation/link/components/__stories__/ActionLink.stories.tsx index bb7dc0de6ad7..eaf20ade7f7b 100644 --- a/packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/ActionLink.stories.tsx +++ b/packages/twenty-ui/src/navigation/link/components/__stories__/ActionLink.stories.tsx @@ -1,7 +1,6 @@ import { Meta, StoryObj } from '@storybook/react'; -import { ComponentDecorator } from 'twenty-ui'; - -import { ActionLink } from '@/ui/navigation/link/components/ActionLink'; +import { ActionLink } from '@ui/navigation/link/components/ActionLink'; +import { ComponentDecorator } from '@ui/testing'; const meta: Meta = { title: 'UI/navigation/link/ActionLink', diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/ContactLink.stories.tsx b/packages/twenty-ui/src/navigation/link/components/__stories__/ContactLink.stories.tsx similarity index 87% rename from packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/ContactLink.stories.tsx rename to packages/twenty-ui/src/navigation/link/components/__stories__/ContactLink.stories.tsx index f4bcf867b5fa..4051c937499e 100644 --- a/packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/ContactLink.stories.tsx +++ b/packages/twenty-ui/src/navigation/link/components/__stories__/ContactLink.stories.tsx @@ -1,8 +1,7 @@ import { Meta, StoryObj } from '@storybook/react'; import { fn } from '@storybook/test'; -import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator'; - +import { ComponentWithRouterDecorator } from '@ui/testing'; import { ContactLink } from '../ContactLink'; const meta: Meta = { diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/GithubVersionLink.stories.tsx b/packages/twenty-ui/src/navigation/link/components/__stories__/GithubVersionLink.stories.tsx similarity index 79% rename from packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/GithubVersionLink.stories.tsx rename to packages/twenty-ui/src/navigation/link/components/__stories__/GithubVersionLink.stories.tsx index e21fe63249d7..2e06aea8a6ea 100644 --- a/packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/GithubVersionLink.stories.tsx +++ b/packages/twenty-ui/src/navigation/link/components/__stories__/GithubVersionLink.stories.tsx @@ -1,7 +1,6 @@ import { Meta, StoryObj } from '@storybook/react'; -import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator'; - +import { ComponentWithRouterDecorator } from '@ui/testing'; import { GithubVersionLink } from '../GithubVersionLink'; const meta: Meta = { diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/RawLink.stories.tsx b/packages/twenty-ui/src/navigation/link/components/__stories__/RawLink.stories.tsx similarity index 89% rename from packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/RawLink.stories.tsx rename to packages/twenty-ui/src/navigation/link/components/__stories__/RawLink.stories.tsx index c2f83757f1d3..8be070812a23 100644 --- a/packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/RawLink.stories.tsx +++ b/packages/twenty-ui/src/navigation/link/components/__stories__/RawLink.stories.tsx @@ -1,8 +1,7 @@ import { Meta, StoryObj } from '@storybook/react'; import { expect, fn, userEvent, within } from '@storybook/test'; -import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator'; - +import { ComponentWithRouterDecorator } from '@ui/testing'; import { RawLink } from '../RawLink'; const meta: Meta = { diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/RoundedLink.stories.tsx b/packages/twenty-ui/src/navigation/link/components/__stories__/RoundedLink.stories.tsx similarity index 89% rename from packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/RoundedLink.stories.tsx rename to packages/twenty-ui/src/navigation/link/components/__stories__/RoundedLink.stories.tsx index 898213169d13..5b9107f1a775 100644 --- a/packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/RoundedLink.stories.tsx +++ b/packages/twenty-ui/src/navigation/link/components/__stories__/RoundedLink.stories.tsx @@ -1,8 +1,7 @@ import { Meta, StoryObj } from '@storybook/react'; import { expect, fn, userEvent, within } from '@storybook/test'; -import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator'; - +import { ComponentWithRouterDecorator } from '@ui/testing'; import { RoundedLink } from '../RoundedLink'; const meta: Meta = { diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/SocialLink.stories.tsx b/packages/twenty-ui/src/navigation/link/components/__stories__/SocialLink.stories.tsx similarity index 91% rename from packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/SocialLink.stories.tsx rename to packages/twenty-ui/src/navigation/link/components/__stories__/SocialLink.stories.tsx index 48fc83fd16b5..0b5880d2cec6 100644 --- a/packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/SocialLink.stories.tsx +++ b/packages/twenty-ui/src/navigation/link/components/__stories__/SocialLink.stories.tsx @@ -1,8 +1,7 @@ import { Meta, StoryObj } from '@storybook/react'; import { expect, fn, userEvent, within } from '@storybook/test'; -import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator'; - +import { ComponentWithRouterDecorator } from '@ui/testing'; import { LinkType, SocialLink } from '../SocialLink'; const meta: Meta = { diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/UndecoratedLink.stories.tsx b/packages/twenty-ui/src/navigation/link/components/__stories__/UndecoratedLink.stories.tsx similarity index 79% rename from packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/UndecoratedLink.stories.tsx rename to packages/twenty-ui/src/navigation/link/components/__stories__/UndecoratedLink.stories.tsx index 1765a9f9e357..172cb915450e 100644 --- a/packages/twenty-front/src/modules/ui/navigation/link/components/__stories__/UndecoratedLink.stories.tsx +++ b/packages/twenty-ui/src/navigation/link/components/__stories__/UndecoratedLink.stories.tsx @@ -1,9 +1,8 @@ import { expect } from '@storybook/jest'; import { Meta, StoryObj } from '@storybook/react'; import { userEvent, within } from '@storybook/test'; - -import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; -import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator'; +import { UndecoratedLink } from '@ui/navigation/link/components/UndecoratedLink'; +import { ComponentWithRouterDecorator } from '@ui/testing'; const meta: Meta = { title: 'UI/navigation/link/UndecoratedLink', diff --git a/packages/twenty-ui/src/navigation/link/components/index.ts b/packages/twenty-ui/src/navigation/link/components/index.ts new file mode 100644 index 000000000000..153a89d7af7a --- /dev/null +++ b/packages/twenty-ui/src/navigation/link/components/index.ts @@ -0,0 +1,8 @@ +export * from './ActionLink'; +export * from './AdvancedSettingsToggle'; +export * from './ContactLink'; +export * from './GithubVersionLink'; +export * from './RawLink'; +export * from './RoundedLink'; +export * from './SocialLink'; +export * from './UndecoratedLink'; diff --git a/packages/twenty-front/src/modules/ui/navigation/link/constants/Cal.ts b/packages/twenty-ui/src/navigation/link/constants/Cal.ts similarity index 100% rename from packages/twenty-front/src/modules/ui/navigation/link/constants/Cal.ts rename to packages/twenty-ui/src/navigation/link/constants/Cal.ts diff --git a/packages/twenty-front/src/modules/ui/navigation/link/constants/GithubLink.ts b/packages/twenty-ui/src/navigation/link/constants/GithubLink.ts similarity index 100% rename from packages/twenty-front/src/modules/ui/navigation/link/constants/GithubLink.ts rename to packages/twenty-ui/src/navigation/link/constants/GithubLink.ts diff --git a/packages/twenty-ui/src/navigation/link/index.ts b/packages/twenty-ui/src/navigation/link/index.ts new file mode 100644 index 000000000000..c46a592e0131 --- /dev/null +++ b/packages/twenty-ui/src/navigation/link/index.ts @@ -0,0 +1,3 @@ +export * from './components'; +export * from './constants/Cal'; +export * from './constants/GithubLink'; diff --git a/packages/twenty-ui/src/testing/decorators/ComponentWithRouterDecorator.tsx b/packages/twenty-ui/src/testing/decorators/ComponentWithRouterDecorator.tsx new file mode 100644 index 000000000000..2ebe92443bbf --- /dev/null +++ b/packages/twenty-ui/src/testing/decorators/ComponentWithRouterDecorator.tsx @@ -0,0 +1,82 @@ +import { Decorator } from '@storybook/react'; +import { + createMemoryRouter, + createRoutesFromElements, + Outlet, + Route, + RouterProvider, +} from 'react-router-dom'; + +import { ComponentStorybookLayout } from '../ComponentStorybookLayout'; + +interface StrictArgs { + [name: string]: unknown; +} +export type RouteParams = { + [param: string]: string; +}; + +export const isRouteParams = (obj: any): obj is RouteParams => { + if (typeof obj !== 'object' || obj === null) { + return false; + } + + return Object.keys(obj).every((key) => typeof obj[key] === 'string'); +}; + +export const computeLocation = ( + routePath: string, + routeParams?: RouteParams, +) => { + return { + pathname: routePath.replace( + /:(\w+)/g, + (paramName) => routeParams?.[paramName] ?? '', + ), + }; +}; + +const Providers = () => ( + + + +); + +const createRouter = ({ + Story, + args, + initialEntries, + initialIndex, +}: { + Story: () => JSX.Element; + args: StrictArgs; + initialEntries?: { + pathname: string; + }[]; + initialIndex?: number; +}) => + createMemoryRouter( + createRoutesFromElements( + }> + } /> + , + ), + { initialEntries, initialIndex }, + ); + +export const ComponentWithRouterDecorator: Decorator = (Story, { args }) => { + return ( + + ); +}; diff --git a/packages/twenty-ui/src/testing/index.ts b/packages/twenty-ui/src/testing/index.ts index 95631bbd7d22..dc67f4a8d5b9 100644 --- a/packages/twenty-ui/src/testing/index.ts +++ b/packages/twenty-ui/src/testing/index.ts @@ -1,6 +1,7 @@ export * from './ComponentStorybookLayout'; export * from './decorators/CatalogDecorator'; export * from './decorators/ComponentDecorator'; +export * from './decorators/ComponentWithRouterDecorator'; export * from './decorators/RouterDecorator'; export * from './mocks/avatarUrlMock'; export * from './types/CatalogStory'; diff --git a/packages/twenty-ui/src/utilities/getDisplayValueByUrlType.ts b/packages/twenty-ui/src/utilities/getDisplayValueByUrlType.ts new file mode 100644 index 000000000000..2325d96c3869 --- /dev/null +++ b/packages/twenty-ui/src/utilities/getDisplayValueByUrlType.ts @@ -0,0 +1,34 @@ +import { LinkType } from '@ui/navigation/link'; +import { isDefined } from './isDefined'; + +type getUrlDisplayValueByUrlTypeProps = { + type: LinkType; + href: string; +}; + +export const getDisplayValueByUrlType = ({ + type, + href, +}: getUrlDisplayValueByUrlTypeProps) => { + if (type === 'linkedin') { + const matches = href.match( + /(?:https?:\/\/)?(?:www.)?linkedin.com\/(?:in|company|school)\/(.*)/, + ); + if (isDefined(matches?.[1])) { + return decodeURIComponent(matches?.[1]); + } else { + return 'LinkedIn'; + } + } + + if (type === 'twitter') { + const matches = href.match( + /(?:https?:\/\/)?(?:www.)?twitter.com\/([-a-zA-Z0-9@:%_+.~#?&//=]*)/, + ); + if (isDefined(matches?.[1])) { + return `@${matches?.[1]}`; + } else { + return '@twitter'; + } + } +}; diff --git a/packages/twenty-ui/src/utilities/index.ts b/packages/twenty-ui/src/utilities/index.ts index 38cd4a1b600a..d393c81ccc84 100644 --- a/packages/twenty-ui/src/utilities/index.ts +++ b/packages/twenty-ui/src/utilities/index.ts @@ -1,4 +1,5 @@ export * from './color/utils/stringToHslColor'; +export * from './getDisplayValueByUrlType'; export * from './image/getImageAbsoluteURI'; export * from './isDefined'; export * from './state/utils/createState'; diff --git a/packages/twenty-website/src/content/twenty-ui/input/toggle.mdx b/packages/twenty-website/src/content/twenty-ui/input/toggle.mdx index cd78b7b58e6d..b86636943963 100644 --- a/packages/twenty-website/src/content/twenty-ui/input/toggle.mdx +++ b/packages/twenty-website/src/content/twenty-ui/input/toggle.mdx @@ -7,7 +7,7 @@ image: /images/user-guide/table-views/table.png - { return ( diff --git a/packages/twenty-website/src/content/twenty-ui/navigation/links.mdx b/packages/twenty-website/src/content/twenty-ui/navigation/links.mdx index 2abf0babf811..dce088149e1f 100644 --- a/packages/twenty-website/src/content/twenty-ui/navigation/links.mdx +++ b/packages/twenty-website/src/content/twenty-ui/navigation/links.mdx @@ -13,7 +13,7 @@ A stylized link component for displaying contact information. { const handleLinkClick = (event) => { @@ -56,7 +56,7 @@ A stylized link component for displaying links. - { @@ -97,7 +97,7 @@ A rounded-styled link with a Chip component for links. - { @@ -134,7 +134,7 @@ Stylized social links, with support for various social link types, such as URLs, - {