Skip to content

Commit

Permalink
feat: migrate namecard page
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanyawat-Arsaga committed Apr 5, 2024
1 parent e2a85fa commit b391564
Show file tree
Hide file tree
Showing 24 changed files with 2,780 additions and 674 deletions.
22 changes: 11 additions & 11 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
"strapi": "strapi"
},
"dependencies": {
"@strapi/plugin-content-type-builder": "^4.21.1",
"@strapi/plugin-email": "^4.21.1",
"@strapi/plugin-graphql": "^4.21.1",
"@strapi/plugin-i18n": "^4.21.1",
"@strapi/plugin-upload": "^4.21.1",
"@strapi/plugin-users-permissions": "^4.21.1",
"@strapi/strapi": "^4.21.1",
"@strapi/typescript-utils": "^4.21.1",
"@strapi/utils": "^4.21.1",
"better-sqlite3": "9.4.3",
"@strapi/plugin-content-type-builder": "^4.22.1",
"@strapi/plugin-email": "^4.22.1",
"@strapi/plugin-graphql": "^4.22.1",
"@strapi/plugin-i18n": "^4.22.1",
"@strapi/plugin-upload": "^4.22.1",
"@strapi/plugin-users-permissions": "^4.22.1",
"@strapi/strapi": "^4.22.1",
"@strapi/typescript-utils": "^4.22.1",
"@strapi/utils": "^4.22.1",
"better-sqlite3": "9.4.5",
"domain-browser": "^5.7.0",
"dotenv": "^16.4.5",
"find-config": "^1.0.0",
"pg": "^8.11.4",
"pg": "^8.11.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^5.2.0",
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added apps/astro/src/assets/namecard/kaho-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/astro/src/assets/namecard/kaho-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/astro/src/assets/namecard/kanata-peek.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 16 additions & 12 deletions apps/astro/src/components/common/LinkItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ComponentUtilsLink } from '~/graphql/generated/client';
import { Link } from '../ui/link';
import { Text } from '../ui/text';

const processUrl = (link: ComponentUtilsLink) => {
const processUrl = (link: Pick<ComponentUtilsLink, 'url' | 'type'>) => {
switch (link.type) {
case 'github':
return link.url?.split('github.com/').splice(-1)[0];
Expand All @@ -13,7 +13,7 @@ const processUrl = (link: ComponentUtilsLink) => {
}
};

const linkIcon = (link: ComponentUtilsLink) => {
const linkIcon = (link: Pick<ComponentUtilsLink, 'type'>) => {
switch (link.type) {
case 'github':
return FaGithub;
Expand All @@ -24,18 +24,22 @@ const linkIcon = (link: ComponentUtilsLink) => {
}
};

export const LinkItem = ({ data }: { data: ComponentUtilsLink }) => {
const Icon = linkIcon(data);
const text = processUrl(data);
export const LinkItem = ({
data,
Icon: _icon,
linkText
}: {
data: Omit<ComponentUtilsLink, 'id'>;
Icon?: React.FunctionComponent;
linkText?: string;
}) => {
const Icon = _icon ? _icon : linkIcon(data);
const text = linkText ? linkText : processUrl(data);
return (
<HStack gap="2">
{Icon && (
<>
<Icon />
<Text>:</Text>
</>
)}

{Icon && <Icon />}
{data.title}
<Text>:</Text>
<Link href={data.url ?? ''} target="_blank">
{text}
</Link>
Expand Down
12 changes: 11 additions & 1 deletion apps/astro/src/components/layout/Navigation.astro
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,17 @@ const NAVIGATION_LINKS = [
];
---

<HStack _print={{ display: 'none' }} p={2} justifyContent="space-between" position="sticky" top="0">
<HStack
_print={{ display: 'none' }}
p={2}
bgColor="bg.default"
borderBottom="1px solid"
borderBottomColor="border.subtle"
justifyContent="space-between"
position="sticky"
top="0"
zIndex="banner"
>
<HStack>
<Link href={getURLWithLanguage('/')}>{t('common.ham')}</Link>
</HStack>
Expand Down
50 changes: 50 additions & 0 deletions apps/astro/src/components/namecard/InteractiveNamecard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Box, Stack, styled } from 'styled-system/jsx';
import { NamecardData } from '~/constants/namecard';
import { Namecard } from './Namecard';

const StyledNamecard = styled(Namecard);

export const InteractiveNamecard = ({ data }: { data: NamecardData }) => {
return (
<Stack
gap="0"
position="relative"
perspective="91mm"
perspectiveOrigin="center"
className="group"
h="full"
w="full"
width="91mm"
height="55mm"
>
<Box
backfaceVisibility="hidden"
position="absolute"
transition="transform"
transitionTimingFunction="linear"
transitionDuration="1s"
transitionDelay="0.1s"
transform={{ base: 'rotateY(0deg)', _groupHover: 'rotateY(180deg)' }}
shadow="md"
top="0"
left="0"
>
<StyledNamecard data={data} side="front" />
</Box>
<Box
backfaceVisibility="hidden"
position="absolute"
transition="transform"
transitionTimingFunction="linear"
transitionDuration="1s"
transitionDelay="0.1s"
transform={{ base: 'rotateY(180deg)', _groupHover: 'rotateY(0deg)' }}
shadow="md"
top="0"
left="0"
>
<StyledNamecard data={data} side="back" />
</Box>
</Stack>
);
};
90 changes: 90 additions & 0 deletions apps/astro/src/components/namecard/Namecard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { Box, Center, HStack, Stack, styled } from 'styled-system/jsx';
import { NamecardData } from '~/constants/namecard';

export const Namecard = ({
data,
side = 'front'
}: {
data: NamecardData;
side: 'front' | 'back';
}) => {
const { color, content, logoTop, logoBottom, logoMiddle, qrCode, Quote } = data;
if (side === 'front') {
return (
<HStack
_print={{
pageBreakBefore: 'always',
// border: '1px solid',
printColorAdjust: 'exact'
}}
width="91mm"
height="55mm"
gap="0"
bgColor="white"
style={{
WebkitPrintColorAdjust: 'exact',
['--main-color' as 'color']: color
}}
>
<Box width="5mm" h="full" bgColor="var(--main-color, #1F1F5A)" />
<Stack flex="1" gap="2" pl="4" pr="2" justifyContent="space-around" h="full" py="4">
<Stack gap="1" fontSize="xs">
<styled.p lineHeight="1">{content.firstRow}</styled.p>
<styled.p>{content.secondRow}</styled.p>
</Stack>
<styled.hr borderColor="var(--main-color)" />
<Stack gap="0">
<styled.h1 fontWeight="semibold" lineHeight="1.12" fontSize="4xl">
{content.name}
</styled.h1>
<styled.p fontSize="sm">{content.nameSubtitle}</styled.p>
</Stack>
<Stack gap="1">
<Stack gap="0" fontSize="xs">
<styled.p>สวัสดีครับ!(サワディーカー)</styled.p>
</Stack>
<Stack gap="0" fontSize="0.5rem">
<styled.p>
X (旧: Twitter): <b>@HamP_punipuni</b>
</styled.p>
<styled.p>
Discord: <b>HamP</b>
</styled.p>
</Stack>
</Stack>
</Stack>
<Stack justifyContent="space-between" py="4" pr="4" h="full" w="84px" alignItems="flex-end">
<styled.img src={logoTop} />
{logoMiddle && <styled.img src={logoMiddle} />}
<styled.img src={logoBottom} />
</Stack>
</HStack>
);
}
return (
<>
<HStack
width="91mm"
height="55mm"
bgColor="white"
gap="0"
border={{ _print: '1px solid' }}
printColorAdjust={{ _print: 'exact' }}
style={{
WebkitPrintColorAdjust: 'exact',
['--main-color' as 'color']: color
}}
>
<Stack flex="1" gap="2" justifyContent="space-evenly" alignItems="center" h="full" p="4">
<Center>
<styled.img maxW="100px" src={qrCode} />
</Center>
<HStack alignItems="center">
<Quote />
</HStack>
</Stack>
<Box width="5mm" h="full" bgColor="var(--main-color, #1F1F5A)" />
</HStack>
</>
);
};
10 changes: 6 additions & 4 deletions apps/astro/src/constants/namecard.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { styled } from 'styled-system/jsx';
import akarinLogo from '../assets/akarin-logo.png';
import akarinQrCode from '../assets/akarin-qr-code.png';
import hasuLogo from '../assets/hasu-logo.jpg';
import hasuQrCode from '../assets/hasu-qr-code.png';
import akarinLogo from '../assets/namecard/akarin-logo.png';
import akarinQrCode from '../assets/namecard/akarin-qr-code.png';
import hasuLogo from '../assets/namecard/hasu-logo.jpg';
import hasuQrCode from '../assets/namecard/hasu-qr-code.png';

export const NAMECARDS = [
{
Expand Down Expand Up @@ -54,3 +54,5 @@ export const NAMECARDS = [
}
}
];

export type NamecardData = (typeof NAMECARDS)[0];
13 changes: 13 additions & 0 deletions apps/astro/src/pages/[locale]/about/index.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
---
import { Container } from 'styled-system/jsx';
import { Heading } from '~/components/ui/heading';
import { localePaths } from '~/i18n/paths';
import { useTranslations } from '~/i18n/utils';
import MainLayout from '~/layouts/MainLayout.astro';
//TODO:
export async function getStaticPaths() {
return localePaths;
}
const { locale } = Astro.params;
const t = useTranslations(locale);
---

<MainLayout>
<Container>
<Heading as="h1" size="2xl" fontWeight="bold">{t('note.notes')}</Heading>
</Container>
</MainLayout>
Loading

0 comments on commit b391564

Please sign in to comment.