-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df10d40
commit 8fada8a
Showing
13 changed files
with
20,718 additions
and
15,596 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,3 +133,5 @@ styled-system | |
.nx | ||
|
||
.strapi | ||
|
||
.idx |
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
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ const t = useTranslations(locale); | |
--- | ||
|
||
<Wrap | ||
_print={{ display: 'none' }} | ||
w="full" | ||
py="2" | ||
px="2" | ||
|
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,41 @@ | ||
import { Tag } from '~/graphql/generated/client'; | ||
import { Badge } from '../ui/badge'; | ||
|
||
export const TagBadge = ({ | ||
tag, | ||
showCount = false, | ||
size | ||
}: { | ||
tag: Tag; | ||
showCount?: boolean; | ||
size?: 'sm' | 'md' | 'lg'; | ||
}) => { | ||
const { title, type } = tag; | ||
|
||
const projectsCount = tag?.projects?.data.length; | ||
|
||
const colorPalette = (() => { | ||
switch (type) { | ||
case 'Frontend': | ||
return 'blue'; | ||
case 'Backend': | ||
return 'red'; | ||
case 'Database': | ||
return 'orange'; | ||
case 'Programming_Language': | ||
return 'green'; | ||
case 'DevOps': | ||
return 'purple'; | ||
case 'Others': | ||
return 'gray'; | ||
case 'Non_Dev': | ||
return 'gray'; | ||
} | ||
})(); | ||
|
||
return ( | ||
<Badge variant="solid" size={size} colorPalette={colorPalette}> | ||
{title} {showCount && !!projectsCount && `(${projectsCount})`} | ||
</Badge> | ||
); | ||
}; |
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
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,28 @@ | ||
import type { TagEntity } from '~graphql/generated/client'; | ||
|
||
const SORT_ORDER = [ | ||
'Frontend', | ||
'Backend', | ||
'Programming_Language', | ||
'Database', | ||
'Dev_Ops', | ||
'NonDev', | ||
'Others' | ||
]; | ||
|
||
const getTypeOrder = (tag: TagEntity) => | ||
tag.attributes?.type && SORT_ORDER.includes(tag.attributes.type) | ||
? SORT_ORDER.indexOf(tag.attributes.type) | ||
: Infinity; | ||
|
||
export const sortTags = (tags: TagEntity[]) => { | ||
return [...tags].sort((a, b) => { | ||
if (!a.attributes || !b.attributes) return 0; | ||
if (a.attributes.order && b.attributes.order) return a.attributes.order - b.attributes.order; | ||
else if (!a.attributes.order && !b.attributes.order) { | ||
return getTypeOrder(a) - getTypeOrder(b); | ||
} else { | ||
return (a.attributes.order || b.attributes.order) as number; | ||
} | ||
}); | ||
}; |
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 kebabCase from 'lodash/kebabCase'; | ||
|
||
export const LANGUAGES = ['en', 'ja']; | ||
|
||
export const getLocalizedItems = < | ||
T extends { locale?: string | null }, | ||
A extends { data?: I[] }, | ||
I extends { attributes?: T | null }, | ||
L extends { localizations?: A | null } | ||
>( | ||
data?: L | null, | ||
locale = 'en' | ||
): T | undefined | null => { | ||
if (!data) return; | ||
const items = data?.localizations?.data; | ||
return items?.find((d) => d?.attributes?.locale === locale)?.attributes ?? items?.[0]?.attributes; | ||
}; | ||
|
||
export const toKebabCase = kebabCase; |
Oops, something went wrong.