Sort socials
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
import { FindSocials } from 'types/graphql'
|
import { FindSocials } from 'types/graphql'
|
||||||
|
|
||||||
import { baseUrls, getLogoComponent } from 'src/lib/handle'
|
import { baseUrls, getLogoComponent, sortOrder } from 'src/lib/handle'
|
||||||
|
|
||||||
const SocialLinks = ({ socials }: FindSocials) => {
|
const SocialLinks = ({ socials }: FindSocials) => (
|
||||||
return (
|
|
||||||
<div className={`grid max-w-68 grid-cols-[repeat(auto-fit,3rem)] gap-2`}>
|
<div className={`grid max-w-68 grid-cols-[repeat(auto-fit,3rem)] gap-2`}>
|
||||||
{[...socials]
|
{[...socials]
|
||||||
.sort((a, b) => (a.type > b.type ? 1 : -1))
|
.sort((a, b) => sortOrder.indexOf(a.type) - sortOrder.indexOf(b.type))
|
||||||
.map((social, i) => (
|
.map((social, i) => (
|
||||||
<div key={i} className="tooltip" data-tip={social.name}>
|
<div key={i} className="tooltip" data-tip={social.name}>
|
||||||
<a
|
<a
|
||||||
@@ -20,7 +19,6 @@ const SocialLinks = ({ socials }: FindSocials) => {
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
export default SocialLinks
|
export default SocialLinks
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { toast } from '@redwoodjs/web/toast'
|
|||||||
|
|
||||||
import { QUERY } from 'src/components/Social/SocialsCell'
|
import { QUERY } from 'src/components/Social/SocialsCell'
|
||||||
import { truncate } from 'src/lib/formatters'
|
import { truncate } from 'src/lib/formatters'
|
||||||
import { getLogoComponent } from 'src/lib/handle'
|
import { getLogoComponent, sortOrder } from 'src/lib/handle'
|
||||||
|
|
||||||
const DELETE_SOCIAL_MUTATION: TypedDocumentNode<
|
const DELETE_SOCIAL_MUTATION: TypedDocumentNode<
|
||||||
DeleteSocialMutation,
|
DeleteSocialMutation,
|
||||||
@@ -58,7 +58,11 @@ const SocialsList = ({ socials }: FindSocials) => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{socials.map((social) => {
|
{[...socials]
|
||||||
|
.sort(
|
||||||
|
(a, b) => sortOrder.indexOf(a.type) - sortOrder.indexOf(b.type)
|
||||||
|
)
|
||||||
|
.map((social) => {
|
||||||
const actionButtons = (
|
const actionButtons = (
|
||||||
<>
|
<>
|
||||||
<Link
|
<Link
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
} from '@icons-pack/react-simple-icons'
|
} from '@icons-pack/react-simple-icons'
|
||||||
import { mdiEmail, mdiLink, mdiPhone } from '@mdi/js'
|
import { mdiEmail, mdiLink, mdiPhone } from '@mdi/js'
|
||||||
import Icon from '@mdi/react'
|
import Icon from '@mdi/react'
|
||||||
import type { Handle } from 'types/graphql'
|
import type { Handle, Social } from 'types/graphql'
|
||||||
|
|
||||||
export const baseUrls: Record<Handle, string> = {
|
export const baseUrls: Record<Handle, string> = {
|
||||||
x: 'https://x.com/',
|
x: 'https://x.com/',
|
||||||
@@ -76,4 +76,26 @@ const logoComponents: Record<Handle, ReactElement> = {
|
|||||||
custom: <Icon path={mdiLink} className="size-7" />,
|
custom: <Icon path={mdiLink} className="size-7" />,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const sortOrder: Social['type'][] = [
|
||||||
|
'phone',
|
||||||
|
'email',
|
||||||
|
'custom',
|
||||||
|
'linkedin',
|
||||||
|
'leetcode',
|
||||||
|
'github',
|
||||||
|
'gitea',
|
||||||
|
'forgejo',
|
||||||
|
'gitlab',
|
||||||
|
'bitbucket',
|
||||||
|
'youtube',
|
||||||
|
'x',
|
||||||
|
'instagram',
|
||||||
|
'tiktok',
|
||||||
|
'facebook',
|
||||||
|
'threads',
|
||||||
|
'twitch',
|
||||||
|
'discord',
|
||||||
|
'steam',
|
||||||
|
]
|
||||||
|
|
||||||
export const getLogoComponent = (type: Handle) => logoComponents[type]
|
export const getLogoComponent = (type: Handle) => logoComponents[type]
|
||||||
|
|||||||
Reference in New Issue
Block a user