-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
13 changed files
with
254 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/app/features/collectibles/components/_collectible-types/collectible-audio.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
import { AudioIcon } from '@app/ui/components/icons/audio-icon'; | ||
|
||
import { CollectibleItemLayout, CollectibleItemLayoutProps } from '../collectible-item.layout'; | ||
import { CollectiblePlaceholderLayout } from './collectible-placeholder.layout'; | ||
|
||
interface CollectibleAudioProps extends Omit<CollectibleItemLayoutProps, 'children'> { | ||
icon: ReactNode; | ||
} | ||
export function CollectibleAudio({ icon, ...props }: CollectibleAudioProps) { | ||
return ( | ||
<CollectibleItemLayout collectibleTypeIcon={icon} {...props}> | ||
<CollectiblePlaceholderLayout> | ||
<AudioIcon size="xl" /> | ||
</CollectiblePlaceholderLayout> | ||
</CollectibleItemLayout> | ||
); | ||
} |
35 changes: 35 additions & 0 deletions
35
src/app/features/collectibles/components/_collectible-types/collectible-iframe.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ReactNode, useState } from 'react'; | ||
|
||
import { Iframe } from '@app/ui/components/iframe'; | ||
|
||
import { CollectibleItemLayout, CollectibleItemLayoutProps } from '../collectible-item.layout'; | ||
import { ImageUnavailable } from '../image-unavailable'; | ||
|
||
interface CollectibleIframeProps extends Omit<CollectibleItemLayoutProps, 'children'> { | ||
icon: ReactNode; | ||
src: string; | ||
} | ||
export function CollectibleIframe({ icon, src, ...props }: CollectibleIframeProps) { | ||
const [isError, setIsError] = useState(false); | ||
|
||
if (isError) | ||
return ( | ||
<CollectibleItemLayout collectibleTypeIcon={icon} {...props}> | ||
<ImageUnavailable /> | ||
</CollectibleItemLayout> | ||
); | ||
|
||
return ( | ||
<CollectibleItemLayout collectibleTypeIcon={icon} {...props}> | ||
<Iframe | ||
aspectRatio="1 / 1" | ||
height="100%" | ||
objectFit="cover" | ||
onError={() => setIsError(true)} | ||
src={src} | ||
width="100%" | ||
zIndex={99} | ||
/> | ||
</CollectibleItemLayout> | ||
); | ||
} |
4 changes: 2 additions & 2 deletions
4
src/app/features/collectibles/components/_collectible-types/collectible-image.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...pp/features/collectibles/components/_collectible-types/collectible-placeholder.layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Flex } from 'leather-styles/jsx'; | ||
|
||
import { HasChildren } from '@app/common/has-children'; | ||
|
||
export function CollectiblePlaceholderLayout({ children }: HasChildren) { | ||
return ( | ||
<Flex | ||
alignItems="center" | ||
bg="accent.component-background-default" | ||
flexDirection="column" | ||
height="100%" | ||
justifyContent="center" | ||
textAlign="center" | ||
width="100%" | ||
> | ||
{children} | ||
</Flex> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 9 additions & 14 deletions
23
src/app/features/collectibles/components/image-unavailable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
import { Flex, styled } from 'leather-styles/jsx'; | ||
import { styled } from 'leather-styles/jsx'; | ||
|
||
import { EyeSlashIcon } from '@app/ui/components/icons/eye-slash-icon'; | ||
|
||
import { CollectiblePlaceholderLayout } from './_collectible-types/collectible-placeholder.layout'; | ||
|
||
export function ImageUnavailable() { | ||
return ( | ||
<Flex | ||
alignItems="center" | ||
bg="accent.component-background-default" | ||
flexDirection="column" | ||
height="100%" | ||
justifyContent="center" | ||
textAlign="center" | ||
width="100%" | ||
> | ||
<EyeSlashIcon pb="12px" size="md" /> | ||
<styled.span textStyle="label.03">Image currently</styled.span> | ||
<styled.span textStyle="label.03">unavailable</styled.span> | ||
</Flex> | ||
<CollectiblePlaceholderLayout> | ||
<EyeSlashIcon size="md" /> | ||
<styled.span pt="space.02" px="space.04" textStyle="label.03"> | ||
Image currently unavailable | ||
</styled.span> | ||
</CollectiblePlaceholderLayout> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { styled } from 'leather-styles/jsx'; | ||
|
||
import { SvgProps } from '@app/ui/ui-types'; | ||
|
||
export function AudioIcon({ size = 'sm', ...props }: SvgProps) { | ||
return ( | ||
<styled.svg | ||
width={size} | ||
height={size} | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
{...props} | ||
> | ||
<path | ||
d="M9.9978 18.5C9.9978 19.8807 8.65466 21 6.9978 21C5.34095 21 3.9978 19.8807 3.9978 18.5C3.9978 17.1193 5.34095 16 6.9978 16C8.65466 16 9.9978 17.1193 9.9978 18.5ZM9.9978 18.5V6.74404C9.9978 6.30243 10.2875 5.91311 10.7105 5.78621L18.7105 3.38621C19.3521 3.19373 19.9978 3.67418 19.9978 4.34404V15.5M19.9978 15.5C19.9978 16.8807 18.6547 18 16.9978 18C15.3409 18 13.9978 16.8807 13.9978 15.5C13.9978 14.1193 15.3409 13 16.9978 13C18.6547 13 19.9978 14.1193 19.9978 15.5Z" | ||
stroke="currentColor" | ||
strokeWidth="2" | ||
strokeLinejoin="round" | ||
/> | ||
</styled.svg> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// __ __ _____ _ _ _____ _ _ _____ | ||
// \ \ / /\ | __ \| \ | |_ _| \ | |/ ____| | ||
// \ \ /\ / / \ | |__) | \| | | | | \| | | __ | ||
// \ \/ \/ / /\ \ | _ /| . ` | | | | . ` | | |_ | | ||
// \ /\ / ____ \| | \ \| |\ |_| |_| |\ | |__| | | ||
// \/ \/_/ \_\_| \_\_| \_|_____|_| \_|\_____| | ||
// | ||
// The purpose of this iframe is to wrap content from external sources, | ||
// primarily for use with inscriptions. Iframes are dangerous and we | ||
// need to be very careful with our use of them. | ||
// | ||
// Below, we use the sandbox attribute to limit what they can do, as well as | ||
// disabling any interaction with pointer events and user selection. | ||
import { HTMLStyledProps, styled } from 'leather-styles/jsx'; | ||
|
||
interface IframeProps extends HTMLStyledProps<'iframe'> { | ||
onError(): void; | ||
src: string; | ||
} | ||
export function Iframe({ onError, src, ...props }: IframeProps) { | ||
return ( | ||
<styled.iframe | ||
loading="lazy" | ||
onError={onError} | ||
overflow="hidden" | ||
pointerEvents="none" | ||
sandbox="allow-scripts" | ||
src={src} | ||
userSelect="none" | ||
{...props} | ||
/> | ||
); | ||
} |
Oops, something went wrong.