fix globe fallback, fix freeform bug
This commit is contained in:
1 parent
013c929cd1
commit
00a31c6366
2 files changed
+29
-17
No files matched your search
@@ -1,17 +1,31 @@
|
|||||||
import { Icon, Row, Text } from '@umami/react-zen';
|
import { Icon, Row, Text } from '@umami/react-zen';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Favicon } from '@/components/common/Favicon';
|
|
||||||
import { Globe, Grid2x2, Link } from '@/components/icons';
|
import { Globe, Grid2x2, Link } from '@/components/icons';
|
||||||
import type { BoardEntityType } from '@/lib/boards';
|
import type { BoardEntityType } from '@/lib/boards';
|
||||||
|
|
||||||
|
const HOSTNAME_REGEX = /^(?:https?:\/\/)?(?:[^@\n]+@)?([^:/\n?=]+)/im;
|
||||||
|
|
||||||
function WebsiteIcon({ domain }: { domain?: string }) {
|
function WebsiteIcon({ domain }: { domain?: string }) {
|
||||||
const [failed, setFailed] = useState(false);
|
const [failed, setFailed] = useState(false);
|
||||||
|
|
||||||
if (domain && !failed) {
|
if (domain && !failed) {
|
||||||
return <Favicon domain={domain} onError={() => setFailed(true)} />;
|
const match = domain.match(HOSTNAME_REGEX);
|
||||||
|
const hostname = match?.[1];
|
||||||
|
|
||||||
|
if (hostname) {
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
src={`https://${hostname}/favicon.ico`}
|
||||||
|
width={16}
|
||||||
|
height={16}
|
||||||
|
alt=""
|
||||||
|
onError={() => setFailed(true)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Globe />;
|
return <Globe width={16} height={16} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function BoardEntityBadge({
|
export function BoardEntityBadge({
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Box, Column, Row } from '@umami/react-zen';
|
import { Column, Heading, Row, Text } from '@umami/react-zen';
|
||||||
import { Panel } from '@/components/common/Panel';
|
import { Panel } from '@/components/common/Panel';
|
||||||
import { useBoard } from '@/components/hooks';
|
import { useBoard } from '@/components/hooks';
|
||||||
import { getBoardType, getResolvedComponentEntity, isOpenBoardType } from '@/lib/boards';
|
import { getBoardType, getResolvedComponentEntity, isOpenBoardType } from '@/lib/boards';
|
||||||
@@ -31,22 +31,20 @@ export function BoardViewColumn({
|
|||||||
const showBadge = showEntityBadge && isOpenBoardType(boardType) && !!entityBadge;
|
const showBadge = showEntityBadge && isOpenBoardType(boardType) && !!entityBadge;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Panel title={title} description={description} height="100%" position="relative">
|
<Panel height="100%">
|
||||||
{showBadge && (
|
{showBadge ? (
|
||||||
title ? (
|
<Row justifyContent={title ? 'space-between' : 'flex-end'} alignItems="center">
|
||||||
<Box position="absolute" top="12px" right="12px" zIndex={100}>
|
{title && <Heading>{title}</Heading>}
|
||||||
<BoardEntityBadge {...entityBadge} />
|
<BoardEntityBadge {...entityBadge} />
|
||||||
</Box>
|
</Row>
|
||||||
) : (
|
) : (
|
||||||
<Row justifyContent="flex-end">
|
title && <Heading>{title}</Heading>
|
||||||
<BoardEntityBadge {...entityBadge} />
|
|
||||||
</Row>
|
|
||||||
)
|
|
||||||
)}
|
)}
|
||||||
|
{description && <Text color="muted">{description}</Text>}
|
||||||
<Column width="100%" height="100%" style={{ minHeight: 0 }}>
|
<Column width="100%" height="100%" style={{ minHeight: 0 }}>
|
||||||
<Box width="100%" flexGrow={1} style={{ minHeight: 0 }}>
|
<Column width="100%" flexGrow={1} style={{ minHeight: 0 }}>
|
||||||
<BoardComponentRenderer config={component} websiteId={entityId} />
|
<BoardComponentRenderer config={component} websiteId={entityId} />
|
||||||
</Box>
|
</Column>
|
||||||
</Column>
|
</Column>
|
||||||
</Panel>
|
</Panel>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user