Migrate to twenty-ui - navigation/link (#7837)
This PR was created by [GitStart](https://gitstart.com/) to address the requirements from this ticket: [TWNTY-7535](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-7535). --- ### Description. Migrate link components to `twenty-ui` \ \ Fixes #7535 --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: gitstart-twenty <140154534+gitstart-twenty@users.noreply.github.com> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
committed by
GitHub
parent
02c34d547f
commit
430644448a
34
packages/twenty-ui/src/utilities/getDisplayValueByUrlType.ts
Normal file
34
packages/twenty-ui/src/utilities/getDisplayValueByUrlType.ts
Normal file
@ -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';
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1,6 +1,7 @@
|
||||
export * from './color/utils/stringToHslColor';
|
||||
export * from './getDisplayValueByUrlType';
|
||||
export * from './image/getImageAbsoluteURI';
|
||||
export * from './isDefined';
|
||||
export * from './screen-size/hooks/useScreenSize';
|
||||
export * from './state/utils/createState';
|
||||
export * from './types/Nullable';
|
||||
export * from './screen-size/hooks/useScreenSize';
|
||||
|
||||
Reference in New Issue
Block a user