theme-ui#Text TypeScript Examples
The following examples show how to use
theme-ui#Text.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: previousNuxt.tsx From slice-machine with Apache License 2.0 | 6 votes |
steps = [
InstallSliceSimulator({
code: `npm install --save nuxt-sm vue-slicezone @nuxtjs/prismic @prismicio/slice-simulator-vue`,
}),
UpdateNuxtConfig,
CreatePage({
instructions: (
<>
In your "pages" directory, create a file called{" "}
<Text variant={"pre"}>slice-simulator.vue</Text> and add the following
code. This page is the route you hit to simulator and develop your
components.
</>
),
code: SliceSimulatorPageCreationInstruction,
}),
UpdateSmJson({}),
CheckSetup({}),
]
Example #2
Source File: Error.tsx From nft-market with MIT License | 6 votes |
Error = () => {
return (
<Flex>
<Image sx={{ width: 100, height: 100 }} src="/icons/icon-512x512.png" />
<Box mt={4} ml={4}>
<Heading as="h2">Metamask not installed</Heading>
<Text mt={2}>
Go to{' '}
<Link href="https://metamask.io" target="_blank">
https://metamask.io
</Link>{' '}
to install it.
</Text>
</Box>
</Flex>
)
}
Example #3
Source File: AgentAvailability.tsx From chat-window with MIT License | 6 votes |
AgentAvailability = ({
hasAvailableAgents,
agentAvailableText,
agentUnavailableText,
}: {
hasAvailableAgents: boolean;
agentAvailableText: string;
agentUnavailableText: string;
}) => {
return (
<Flex
px={20}
py={1}
sx={{
bg: 'lighter',
borderTop: '1px solid rgba(230, 230, 230, 0.25)',
alignItems: 'center',
}}
>
<Box
mr={2}
sx={{
height: 8,
width: 8,
bg: hasAvailableAgents ? 'green' : 'muted',
border: '1px solid #fff',
borderRadius: '50%',
}}
></Box>
<Text sx={{color: 'offset', fontSize: 12}}>
{hasAvailableAgents ? agentAvailableText : agentUnavailableText}
</Text>
</Flex>
);
}
Example #4
Source File: ContractDetails.tsx From nft-market with MIT License | 6 votes |
ContractDetails = () => {
const { contractDetails } = useAppState()
return (
<Box>
<Heading as="h1">NFT Contract Details</Heading>
<Grid my={3}>
{contractDetails &&
Object.keys(contractDetails).map(a => (
<Text key={a}>
{a}:{' '}
<Text variant="text.bold" as="span">
{contractDetails[a as keyof ContractPropsDetails]}
</Text>
</Text>
))}
</Grid>
</Box>
)
}
Example #5
Source File: VersionBadge.tsx From slice-machine with Apache License 2.0 | 6 votes |
VersionBadge: React.FC<VersionBadgeProps> = ({
isSelected,
onClick,
versionNumber,
tag,
}) => {
return (
<Flex
sx={{
p: 1,
borderRadius: "4px",
cursor: "pointer",
transition: "200ms all",
justifyContent: "space-between",
alignItems: "center",
...(!isSelected
? {
"&:hover": {
bg: "grey01",
},
}
: {
color: "purple",
bg: transparentize("purple", 0.95),
}),
}}
onClick={onClick}
>
<Text>{versionNumber}</Text>
{tag && <VersionTag type={tag} />}
</Flex>
);
}
Example #6
Source File: Header.tsx From nft-market with MIT License | 5 votes |
Header = () => {
const history = useHistory()
const location = useLocation()
const { user, isAuthenticated } = useAppState()
return (
<Box bg="black">
<Flex sx={{ alignItems: 'center', p: 3 }} as="nav">
<Image
onClick={() => {
history.push('/')
}}
sx={{ width: 50, cursor: 'pointer' }}
src="/static/logo.png"
/>
<Heading sx={{ ml: [1, 2], color: 'white' }} as="h4">
ERC721 Marketplace{' '}
<Text sx={{ display: ['none', 'block'] }}>+ OpenSea.io on Rinkeby Network</Text>
</Heading>
<UserMenu />
</Flex>
{isAuthenticated && user && (
<Flex bg="midGray" py={3} sx={{ justifyContent: 'center' }}>
<NavLink
sx={{
pointerEvents: location.pathname === '/' ? 'none' : 'visible',
color: location.pathname === '/' ? 'green' : 'white',
}}
onClick={() => history.push('/')}
>
Marketplace
</NavLink>
<Box sx={{ width: 50 }} />
<NavLink
sx={{
pointerEvents: location.pathname === '/profile' ? 'none' : 'visible',
color: location.pathname === '/profile' ? 'green' : 'white',
}}
onClick={() => history.push('/profile')}
>
Profile
</NavLink>
</Flex>
)}
</Box>
)
}
Example #7
Source File: CodeBlock.tsx From slice-machine with Apache License 2.0 | 5 votes |
CodeBlock: React.FC<CodeBlockProps> = ({ code, lang }) => {
const { theme } = useThemeUI();
const [isCopied, setIsCopied] = useState(false);
const copy = (): void => {
code &&
navigator.clipboard.writeText(code).then(() => {
setIsCopied(true);
setTimeout(() => {
setIsCopied(false);
}, 1200);
});
};
return code ? (
<Flex
sx={{
p: 2,
px: 3,
alignItems: "center",
borderTop: "1px solid",
borderColor: "borders",
justifyContent: "space-between",
}}
>
<Flex
sx={{
alignItems: "center",
display: ["none", "none", "flex"],
maxWidth: "80%",
}}
>
<BsCode
size={26}
color={theme?.colors?.icons as string | undefined}
style={{
border: "1px solid",
borderColor: theme?.colors?.borders as string | undefined,
borderRadius: "3px",
padding: "4px",
marginRight: "2px",
}}
/>
<Code
sx={{
margin: "0px 8px",
border: "none",
borderRadius: "3px",
fontSize: "13px",
}}
lang={lang}
>
{code}
</Code>
</Flex>
<Box>
<Button onClick={copy} variant="textButton">
{isCopied ? (
<MdCheck
size={16}
color={theme?.colors?.success as string | undefined}
style={buttonIconStyle}
/>
) : (
<BiCopy size={16} style={buttonIconStyle} />
)}
<Text
as="span"
sx={{ display: ["none", "inline", "none", "inline"] }}
>
Copy
</Text>
</Button>
</Box>
</Flex>
) : null;
}
Example #8
Source File: ChatMessage.tsx From chat-window with MIT License | 5 votes |
ChatMessage = ({
message,
isMe,
companyName,
isLastInGroup,
shouldDisplayTimestamp,
}: Props) => {
const {body, created_at, user, type, attachments = []} = message;
const created = created_at ? dayjs.utc(created_at) : null;
const timestamp = created ? formatRelativeTime(created) : null;
const isBot = type === 'bot';
const defaultBotName = companyName || 'Bot';
const identifer = isBot ? defaultBotName : getAgentIdentifier(user);
if (isMe) {
return (
<Box pr={0} pl={4} pb={isLastInGroup ? 3 : 2}>
<Flex sx={{justifyContent: 'flex-end'}}>
<ChatMessageBody
className="Text--white"
sx={{
color: 'background',
bg: 'primary',
whiteSpace: 'pre-wrap',
}}
content={body}
attachments={attachments}
/>
</Flex>
{shouldDisplayTimestamp && (
<Flex m={1} sx={{justifyContent: 'flex-end'}}>
<Text sx={{color: 'gray'}}>
{timestamp ? `Sent ${timestamp}` : 'Sending...'}
</Text>
</Flex>
)}
</Box>
);
}
return (
<Box pr={4} pl={0} pb={isLastInGroup ? 3 : 2}>
<Flex sx={{justifyContent: 'flex-start', alignItems: 'center'}}>
<SenderAvatar name={identifer} user={user} isBot={isBot} />
<ChatMessageBody
sx={{
color: 'text',
bg: 'rgb(245, 245, 245)',
whiteSpace: 'pre-wrap',
}}
content={body}
attachments={attachments}
/>
</Flex>
{shouldDisplayTimestamp && (
<Flex m={1} sx={{justifyContent: 'flex-start'}}>
<Text sx={{color: 'gray'}}>
{identifer} · Sent {timestamp}
</Text>
</Flex>
)}
</Box>
);
}
Example #9
Source File: UpdateCommandBox.tsx From slice-machine with Apache License 2.0 | 5 votes |
UpdateCommandBox: React.FC<UpdateCommandBoxProps> = ({
changelog,
selectedVersion,
packageManager,
}) => {
const isLatest =
selectedVersion.versionNumber === changelog.versions[0].versionNumber;
const packageToInstall = `slice-machine-ui@${
isLatest ? "latest" : selectedVersion.versionNumber
}`;
const updateCommand =
packageManager === "yarn"
? `yarn add --dev ${packageToInstall}`
: `npm install --save-dev ${packageToInstall}`;
return (
<Flex
sx={{
flexDirection: "column",
gap: "16px",
padding: "16px",
bg: "grey01",
}}
>
<Text
sx={{
fontSize: "16px",
fontWeight: 500,
lineHeight: "20px",
}}
>
How to install
</Text>
<Flex
sx={{
gap: "8px",
}}
>
<CodeBlock
codeStyle={{ color: "white", minWidth: "480px", padding: "8px" }}
>
{updateCommand}
</CodeBlock>
<Button
variant="secondary"
onClick={() => void navigator.clipboard.writeText(updateCommand)}
>
Copy
</Button>
</Flex>
</Flex>
);
}
Example #10
Source File: Token.tsx From nft-market with MIT License | 4 votes |
Token = ({ token, isOnSale, onTransfer, onBuy, onSale }: TokenCompProps) => {
const [transfer, setTransfer] = useState<boolean>(false)
const [onSaleActive, setOnSale] = useState<boolean>(false)
const [address, setAddress] = useState<string>('')
const [price, setPrice] = useState<string>('')
const { user, ethPrice, contractDetails, transferToken, buyToken, setTokenSale } = useAppState()
const onTransferClick = async (e: FormEvent | MouseEvent) => {
e.preventDefault()
if (onTransfer && utils.isAddress(address)) {
transferToken(token.id, address)
setTransfer(false)
}
}
const onBuyClick = (e: MouseEvent) => {
e.preventDefault()
onBuy && buyToken(token.id, token.price)
}
const onSaleClick = async (e: MouseEvent) => {
e.preventDefault()
if (!onSale) return
try {
await setTokenSale(token.id, utils.parseEther(price), true)
setOnSale(false)
} catch (e) {
throw e
}
}
const { data: owner } = useSWR(token.id, fetchOwner)
const { data } = useSWR(`${METADATA_API}/token/${token.id}`, fetcherMetadata)
const tokenPriceEth = formatPriceEth(token.price, ethPrice)
if (!data)
return (
<Card variant="nft">
<Spinner />
</Card>
)
if (!data.name) return null
return (
<Card variant="nft">
<Image
sx={{ width: '100%', bg: 'white', borderBottom: '1px solid black' }}
src={data.image}
/>
<Box p={3} pt={2}>
<Heading as="h2">{data.name}</Heading>
<Divider variant="divider.nft" />
<Box>
<Text sx={{ color: 'lightBlue', fontSize: 1, fontWeight: 'bold' }}>Price</Text>
<Heading as="h3" sx={{ color: 'green', m: 0, fontWeight: 'bold' }}>
{constants.EtherSymbol} {Number(utils.formatEther(token.price)).toFixed(2)}{' '}
<Text sx={{ color: 'navy' }} as="span" variant="text.body">
({tokenPriceEth})
</Text>
</Heading>
{owner && typeof owner === 'string' && !onTransfer && (
<Box mt={2}>
<Text as="p" sx={{ color: 'lightBlue', fontSize: 1, fontWeight: 'bold' }}>
Owner
</Text>
<NavLink
target="_blank"
href={`https://rinkeby.etherscan.io/address/${owner}`}
variant="owner"
style={{
textOverflow: 'ellipsis',
width: '100%',
position: 'relative',
overflow: 'hidden',
}}
>
{toShort(owner)}
</NavLink>
</Box>
)}
<Box mt={2}>
<NavLink
target="_blank"
href={`https://testnets.opensea.io/assets/${contractDetails?.address}/${token.id}`}
variant="openSea"
>
View on Opensea.io
</NavLink>
</Box>
</Box>
{onTransfer && (
<Flex mt={3} sx={{ justifyContent: 'center' }}>
{transfer && (
<Box sx={{ width: '100%' }}>
<Flex
onSubmit={onTransferClick}
sx={{ width: '100%', flexDirection: 'column' }}
as="form"
>
<Input
onChange={e => setAddress(e.currentTarget.value)}
placeholder="ETH Address 0x0..."
/>
</Flex>
<Flex mt={2}>
<Button sx={{ bg: 'green' }} onClick={onTransferClick} variant="quartiary">
Confirm
</Button>
<Button
sx={{ bg: 'red' }}
ml={2}
onClick={() => setTransfer(false)}
variant="quartiary"
>
Cancel
</Button>
</Flex>
</Box>
)}
{onSaleActive && (
<Box sx={{ width: '100%' }}>
<Flex
onSubmit={onTransferClick}
sx={{ width: '100%', flexDirection: 'column' }}
as="form"
>
<Input
onChange={e => setPrice(e.currentTarget.value)}
placeholder="Token Price in ETH"
/>
</Flex>
<Flex mt={2}>
<Button sx={{ bg: 'green' }} onClick={onSaleClick} variant="quartiary">
Confirm
</Button>
<Button
sx={{ bg: 'red' }}
ml={2}
onClick={() => setOnSale(false)}
variant="quartiary"
>
Cancel
</Button>
</Flex>
</Box>
)}
{!transfer && !onSaleActive && (
<Flex sx={{ flexDirection: 'column', width: '100%', justifyContent: 'center' }}>
<Button onClick={() => setTransfer(!transfer)} variant="tertiary">
Transfer
</Button>
{isOnSale ? (
<Button
mt={2}
onClick={() => onSale && setTokenSale(token.id, token.price, false)}
variant="tertiary"
>
Remove from Sale
</Button>
) : (
<Button mt={2} onClick={() => setOnSale(!onSaleActive)} variant="tertiary">
Put Token for Sale
</Button>
)}
</Flex>
)}
</Flex>
)}
{onBuy && (
<Flex mt={3} sx={{ justifyContent: 'center', width: '100%' }}>
<Button
sx={{
opacity: !!user?.ownedTokens.find(
a => utils.formatUnits(a.id) === utils.formatUnits(token.id)
)
? 0.5
: 1,
pointerEvents: !!user?.ownedTokens.find(
a => utils.formatUnits(a.id) === utils.formatUnits(token.id)
)
? 'none'
: 'visible',
}}
onClick={onBuyClick}
variant="quartiary"
>
Buy Token
</Button>
</Flex>
)}
</Box>
</Card>
)
}
Example #11
Source File: ChatWindow.tsx From chat-window with MIT License | 4 votes |
render() {
const {
title = 'Welcome!',
subtitle = 'How can we help you?',
newMessagePlaceholder = 'Start typing...',
emailInputPlaceholder = 'Enter your email',
agentAvailableText = "We're online right now!",
agentUnavailableText = "We're away at the moment.",
newMessagesNotificationText = 'View new messages',
companyName,
isMobile = false,
isCloseable = true,
showAgentAvailability = false,
accountId,
baseUrl,
} = this.props;
const {
customerId,
messages = [],
availableAgents = [],
isSending,
isOpen,
isTransitioning,
isGameMode,
shouldDisplayNotifications,
shouldDisplayBranding,
} = this.state;
if (isGameMode) {
return (
<EmbeddedGame
isMobile={isMobile}
onLoadGame={this.handleGameLoaded}
onLeaveGame={this.handleLeaveGameMode}
/>
);
}
if (isTransitioning) {
return null; // TODO: need to figure out the best way to handle this
}
if (!isOpen && shouldDisplayNotifications) {
return (
<UnreadMessages
messages={this.getUnreadMessages()}
newMessagesNotificationText={newMessagesNotificationText}
isMobile={isMobile}
onOpen={this.emitOpenWindow}
/>
);
}
// FIXME: only return null for versions of the chat-widget after v1.1.0
if (!isOpen && !this.isOnDeprecatedVersion()) {
return null;
}
const shouldAskForEmail = this.askForEmailUpfront();
const hasAvailableAgents = availableAgents.length > 0;
const replies = this.getQuickReplies(messages);
return (
<Flex
className={isMobile ? 'Mobile' : ''}
sx={{
bg: 'background',
flexDirection: 'column',
height: '100%',
width: '100%',
flex: 1,
}}
>
<Box sx={{bg: 'primary', position: 'relative'}}>
<Box pt={3} pb={showAgentAvailability ? 12 : 16} px={20}>
{/* TODO: wrap in a button element */}
{isCloseable && !this.isOnDeprecatedVersion() && (
<CloseIcon
className="CloseIcon"
width={24}
height={24}
onClick={this.emitCloseWindow}
/>
)}
<Heading
as="h2"
className="Papercups-heading"
sx={{color: 'background', my: 1, mr: 12}}
>
{title}
</Heading>
<Text sx={{color: 'offset'}}>{subtitle}</Text>
</Box>
{showAgentAvailability && (
<AgentAvailability
hasAvailableAgents={hasAvailableAgents}
agentAvailableText={agentAvailableText}
agentUnavailableText={agentUnavailableText}
/>
)}
</Box>
<Box
p={3}
sx={{
flex: 1,
boxShadow: 'rgba(0, 0, 0, 0.2) 0px 21px 4px -20px inset',
overflowY: 'scroll',
}}
>
{messages.map((msg, key) => {
// Slight hack
const next = messages[key + 1];
const isLastInGroup = next
? msg.customer_id !== next.customer_id
: true;
const shouldDisplayTimestamp = key === messages.length - 1;
// NB: `msg.type` doesn't come from the server, it's just a way to
// help identify unsent messages in the frontend for now
const isMe = isCustomerMessage(msg, customerId);
return (
<motion.div
key={key}
initial={{opacity: 0, x: isMe ? 2 : -2}}
animate={{opacity: 1, x: 0}}
transition={{duration: 0.2, ease: 'easeIn'}}
>
<ChatMessage
key={key}
message={msg}
isMe={isMe}
companyName={companyName}
isLastInGroup={isLastInGroup}
shouldDisplayTimestamp={shouldDisplayTimestamp}
/>
</motion.div>
);
})}
{replies && replies.length > 0 ? (
<QuickReplies
replies={replies}
onSelect={this.handleSelectQuickReply}
/>
) : null}
<div ref={(el) => (this.scrollToEl = el)} />
</Box>
{shouldDisplayBranding && <PapercupsBranding />}
<Box
px={2}
sx={{
borderTop: '1px solid rgb(230, 230, 230)',
// TODO: only show shadow on focus TextArea below
boxShadow: 'rgba(0, 0, 0, 0.1) 0px 0px 100px 0px',
}}
>
{/*
NB: we use a `key` prop here to force re-render on open so
that the input will auto-focus appropriately
*/}
<ChatFooter
key={isOpen ? 1 : 0}
accountId={accountId}
baseUrl={baseUrl}
placeholder={newMessagePlaceholder}
emailInputPlaceholder={emailInputPlaceholder}
isSending={isSending}
shouldRequireEmail={shouldAskForEmail}
onSendMessage={this.handleSendMessage}
/>
</Box>
<img
alt="Papercups"
src="https://papercups.s3.us-east-2.amazonaws.com/papercups-logo.svg"
width="0"
height="0"
/>
</Flex>
);
}
Example #12
Source File: slices.tsx From slice-machine with Apache License 2.0 | 4 votes |
SlicesIndex: React.FunctionComponent = () => {
const libraries = useContext(LibrariesContext);
const { openCreateSliceModal, closeCreateSliceModal, createSlice } =
useSliceMachineActions();
const { isCreateSliceModalOpen, isCreatingSlice, localLibs, remoteLibs } =
useSelector((store: SliceMachineStoreType) => ({
isCreateSliceModalOpen: isModalOpen(store, ModalKeysEnum.CREATE_SLICE),
isCreatingSlice: isLoading(store, LoadingKeysEnum.CREATE_SLICE),
localLibs: getLibraries(store),
remoteLibs: getRemoteSlices(store),
}));
const _onCreate = ({
sliceName,
from,
}: {
sliceName: string;
from: string;
}) => {
createSlice(sliceName, from);
};
const localLibraries: LibraryState[] | undefined = libraries?.filter(
(l) => l.isLocal
);
const sliceCount = (libraries || []).reduce((count, lib) => {
if (!lib) {
return count;
}
return count + lib.components.length;
}, 0);
return (
<>
<Container
sx={{
display: "flex",
flex: 1,
}}
>
<Box
as={"main"}
sx={{
flex: 1,
display: "flex",
flexDirection: "column",
}}
>
<Header
ActionButton={
localLibraries?.length != 0 && sliceCount != 0 ? (
<CreateSliceButton
onClick={openCreateSliceModal}
loading={isCreatingSlice}
/>
) : undefined
}
MainBreadcrumb={
<>
<MdHorizontalSplit /> <Text ml={2}>Slices</Text>
</>
}
breadrumbHref="/slices"
/>
{libraries && (
<Flex
sx={{
flex: 1,
flexDirection: "column",
}}
>
{sliceCount === 0 ? (
<Flex
sx={{
flex: 1,
justifyContent: "center",
alignItems: "center",
}}
>
<EmptyState
title={"What are Slices?"}
onCreateNew={openCreateSliceModal}
isLoading={isCreatingSlice}
buttonText={"Create one"}
documentationComponent={
<>
Slices are sections of your website. Prismic documents
contain a dynamic "Slice Zone" that allows content
creators to add, edit, and rearrange Slices to compose
dynamic layouts for any page design.{" "}
<Link
target={"_blank"}
href={"https://prismic.io/docs/core-concepts/slices"}
sx={(theme) => ({ color: theme?.colors?.primary })}
>
Learn more
</Link>
.
</>
}
/>
</Flex>
) : (
libraries.map((lib: LibraryState) => {
const { name, isLocal, components } = lib;
return (
<Flex
key={name}
sx={{
flexDirection: "column",
"&:not(last-of-type)": {
mb: 4,
},
}}
>
<Flex
sx={{
alignItems: "center",
justifyContent: "space-between",
}}
>
<Flex
sx={{
alignItems: "center",
fontSize: 3,
lineHeight: "48px",
fontWeight: "heading",
mb: 1,
}}
>
<Text>{name}</Text>
</Flex>
{!isLocal && <p>⚠️ External libraries are read-only</p>}
</Flex>
<Grid
elems={components.map(([e]) => e)}
defineElementKey={(slice: SliceState) =>
slice.model.name
}
renderElem={(slice: SliceState) => {
return SharedSlice.render({
displayStatus: true,
slice,
});
}}
/>
</Flex>
);
})
)}
</Flex>
)}
</Box>
</Container>
{localLibraries && localLibraries.length > 0 && (
<CreateSliceModal
isCreatingSlice={isCreatingSlice}
isOpen={isCreateSliceModalOpen}
close={closeCreateSliceModal}
libraries={localLibs}
remoteSlices={remoteLibs}
onSubmit={({ sliceName, from }) => _onCreate({ sliceName, from })}
/>
)}
</>
);
}
Example #13
Source File: ModalMapSelect.tsx From HappyIslandDesigner with MIT License | 4 votes |
function IslandLayoutSelector() {
const [layoutType, setLayoutType] = useState<LayoutType>(LayoutType.none);
const [layout, setLayout] = useState<number>(-1);
const [help, setHelp] = useState<boolean>(false);
useEffect(() => {
if (layout != -1)
{
const layoutData = getLayouts(layoutType)[layout];
loadMapFromJSONString(layoutData.data);
CloseMapSelectModal();
}
}, [layoutType, layout]);
function getLayouts(type: LayoutType) {
switch (type) {
case LayoutType.west:
return Layouts.west;
case LayoutType.south:
return Layouts.south;
case LayoutType.east:
return Layouts.east;
case LayoutType.blank:
return Layouts.blank;
}
return [];
}
if (help) {
return (
<Flex p={[0, 3]} sx={{flexDirection: 'column', alignItems: 'center', position: 'relative'}}>
<Box sx={{position: 'absolute', left: 0, top: [1, 30]}}>
<Button variant='icon' onClick={() => setHelp(false)}>
<Image sx={{width: 'auto'}} src='static/img/back.png' />
</Button>
</Box>
<Image sx={{width: 100, margin: 'auto'}} src={'static/img/blathers.png'}/>
<Heading m={3} sx={{px: layoutType ? 4 : 0, textAlign: 'center'}}>{'Please help contribute!'}</Heading>
<Text my={2}>{'Sorry, we don\'t have all the map templates yet (there are almost 100 river layouts in the game!). Each option you see here has been hand-made by a member of the community.'}</Text>
<Text my={2}>{'You can use the \'Upload Screenshot\' tool to trace an image of your island. When you\'re done please consider contributing your island map in either the '}<Link href={'https://github.com/eugeneration/HappyIslandDesigner/issues/59'}>Github</Link>{' or '}<Link href={'https://discord.gg/EtaqD5H'}>Discord</Link>!</Text>
<Text my={2}>{'Please note that your island may have different shaped rock formations, beaches, and building positions than another island with the same river layout.'}</Text>
</Flex>
)
}
let content;
if (layoutType != LayoutType.none) {
var layouts: Array<Layout> = getLayouts(layoutType);
content = (
<Grid
gap={0}
columns={[2, 3, 4]}
sx={{justifyItems: 'center' }}>
{
layouts.map((layout, index) => (
<Card
key={index}
onClick={() => {
confirmDestructiveAction(
'Clear your map? You will lose all unsaved changes.',
() => {
setLayout(index);
});
}}>
<Image variant='card' src={`static/img/layouts/${layoutType}-${layout.name}.png`}/>
</Card>
)).concat(
<Card key={'help'} onClick={()=>{setHelp(true)}}>
<Image sx={{width: 24}} src={'static/img/menu-help.png'} />
<Text sx={{fontFamily: 'body'}}>{'Why isn\'t my map here?'}</Text>
</Card>
)
}
</Grid>
);
}
else {
content = (
<Flex sx={{flexDirection: ['column', 'row'], alignItems: 'center'}}>
<Card onClick={() => setLayoutType(LayoutType.west)}><Image variant='card' src={'static/img/island-type-west.png'}/></Card>
<Card onClick={() => setLayoutType(LayoutType.south)}><Image variant='card' src={'static/img/island-type-south.png'}/></Card>
<Card onClick={() => setLayoutType(LayoutType.east)}><Image variant='card' src={'static/img/island-type-east.png'}/></Card>
<Card onClick={() => {
setLayoutType(LayoutType.blank);
confirmDestructiveAction(
'Clear your map? You will lose all unsaved changes.',
() => {
setLayout(0);
});
}}><Image variant='card' src={'static/img/island-type-blank.png'}/></Card> </Flex>
);
}
return (
<Box p={[0, 3]} sx={{position: 'relative'}}>
{layoutType && <Box sx={{position: 'absolute', top: [1, 3]}}>
<Button variant='icon' onClick={() => setLayoutType(LayoutType.none)}>
<Image src='static/img/back.png' />
</Button>
</Box>}
<Heading m={2} sx={{px: layoutType ? 4 : 0, textAlign: 'center'}}>{layoutType ? 'Choose your Island!' : 'Choose your Layout!'}</Heading>
{layoutType && <Text m={2} sx={{textAlign: 'center'}}>{'You probably won\'t find an exact match, but pick one that roughly resembles your island.'}</Text>}
{content}
</Box>
);
}
Example #14
Source File: CartSidebarView.tsx From nextjs-shopify with MIT License | 4 votes |
CartSidebarView: FC = () => {
const checkoutUrl = useCheckoutUrl()
const cart = useCart()
const subTotal = cart?.subtotalPrice
const total = ' - '
const items = cart?.lineItems ?? []
const isEmpty = items.length === 0
const [cartUpsell, setCartUpsell] = useState()
useEffect(() => {
async function fetchContent() {
const items = cart?.lineItems || []
const cartUpsellContent = await builder
.get('cart-upsell-sidebar', {
cacheSeconds: 120,
userAttributes: {
itemInCart: items.map((item: any) => item.variant.product.handle),
} as any,
})
.toPromise()
setCartUpsell(cartUpsellContent)
}
fetchContent()
}, [cart?.lineItems])
return (
<Themed.div
sx={{
height: '100%',
overflow: 'auto',
paddingBottom: 5,
bg: 'text',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
px: 2,
color: 'background',
...(isEmpty && { justifyContent: 'center' }),
}}
>
{isEmpty ? (
<>
<Bag />
Your cart is empty
<Text>
Biscuit oat cake wafer icing ice cream tiramisu pudding cupcake.
</Text>
</>
) : (
<>
{items.map((item: any) => (
<CartItem
key={item.id}
item={item}
// todo update types
currencyCode={item.variant?.priceV2?.currencyCode || 'USD'}
/>
))}
<Card sx={{ marginLeft: 'auto', minWidth: '10rem', paddingLeft: 5 }}>
<Grid gap={1} columns={2} sx={{ my: 3 }}>
<Text>Subtotal:</Text>
<Text sx={{ marginLeft: 'auto' }}>{subTotal}</Text>
<Text>Shipping:</Text>
<Text sx={{ marginLeft: 'auto' }}> - </Text>
<Text>Tax: </Text>
<Text sx={{ marginLeft: 'auto' }}> - </Text>
</Grid>
<Divider />
<Grid gap={1} columns={2}>
<Text variant="bold">Estimated Total:</Text>
<Text variant="bold" sx={{ marginLeft: 'auto' }}>
{total}
</Text>
</Grid>
</Card>
<BuilderComponent content={cartUpsell} model="cart-upsell-sidebar" />
{checkoutUrl && (
<NavLink
variant="nav"
sx={{ width: '100%', m: 2, p: 12, textAlign: 'center' }}
href={checkoutUrl!}
>
Proceed to Checkout
</NavLink>
)}
</>
)}
</Themed.div>
)
}
Example #15
Source File: index.tsx From slice-machine with Apache License 2.0 | 4 votes |
Navigation: React.FC<NavigationProps> = ({
changelog,
selectedVersion,
selectVersion,
}) => {
const latestVersion: string | undefined =
changelog.versions[0]?.versionNumber;
function findVersionTag(versionNumber: string): VersionTags | null {
switch (versionNumber) {
case latestVersion:
return VersionTags.Latest;
case changelog.latestNonBreakingVersion:
return VersionTags.LatestNonBreaking;
case changelog.currentVersion:
return VersionTags.Current;
default:
return null;
}
}
return (
<Flex
sx={{
width: "244px",
minWidth: "244px",
height: "100%",
borderRight: "1px solid",
borderColor: "grey01",
flexDirection: "column",
padding: "32px 48px 0px 16px",
}}
>
<Flex
sx={{
flexDirection: "column",
borderBottom: "1px solid",
borderColor: "grey01",
paddingBottom: "28px",
}}
>
<Text
sx={{
fontSize: "20px",
fontWeight: 500,
lineHeight: "32px",
}}
>
Changelog
</Text>
<Text
sx={{
fontSize: "16px",
fontWeight: 500,
lineHeight: "24px",
marginTop: "28px",
}}
>
All versions
</Text>
</Flex>
<Flex
sx={{
mt: "24px",
flexDirection: "column",
gap: "4px",
overflow: "auto",
}}
>
{changelog.versions.map((version, index) => (
<VersionBadge
key={`versionBadge-${version.versionNumber}-${index}`}
isSelected={
selectedVersion?.versionNumber === version.versionNumber
}
onClick={() => selectVersion(version)}
versionNumber={version.versionNumber}
tag={findVersionTag(version.versionNumber)}
/>
))}
</Flex>
</Flex>
);
}