Release 2025-05-22-16vM

This commit is contained in:
pluja
2025-05-22 22:38:41 +00:00
parent d79bedf219
commit 72c238a4dc
12 changed files with 392 additions and 268 deletions

View File

@@ -19,6 +19,7 @@ type Props<Tag extends 'a' | 'button' | 'label' = 'button'> = Polymorphic<
dataAstroReload?: boolean
children?: never
disabled?: boolean
inlineIcon?: boolean
}
>
@@ -143,6 +144,7 @@ const {
role,
dataAstroReload,
disabled,
inlineIcon,
...htmlProps
} = Astro.props
@@ -164,11 +166,11 @@ const ActualTag = disabled && Tag === 'a' ? 'span' : Tag
{...dataAstroReload && { 'data-astro-reload': dataAstroReload }}
{...htmlProps}
>
{!!icon && <Icon name={icon} class={iconSlot({ class: classNames?.icon })} />}
{!!icon && <Icon name={icon} class={iconSlot({ class: classNames?.icon })} is:inline={inlineIcon} />}
{!!label && <span class={labelSlot({ class: classNames?.label })}>{label}</span>}
{
!!endIcon && (
<Icon name={endIcon} class={endIconSlot({ class: classNames?.endIcon })}>
<Icon name={endIcon} class={endIconSlot({ class: classNames?.endIcon })} is:inline={inlineIcon}>
{endIcon}
</Icon>
)

View File

@@ -88,12 +88,26 @@ const overallScoreInfo = makeOverallScoreInfo(overallScore)
<h3 class="font-title text-lg leading-none font-medium tracking-wide text-white">
{name}{
statusIcon && (
<Tooltip text={statusIcon.label} position="right" class="-my-2 shrink-0">
<Icon
is:inline={inlineIcons}
name={statusIcon.icon}
class={cn('inline-block size-6 shrink-0 rounded-lg p-1', statusIcon.classNames.icon)}
/>
<Tooltip
text={statusIcon.label}
position="right"
class="-my-2 shrink-0 whitespace-nowrap"
enabled={verificationStatus !== 'VERIFICATION_FAILED'}
>
{[
<Icon
is:inline={inlineIcons}
name={statusIcon.icon}
class={cn(
'inline-block size-6 shrink-0 rounded-lg p-1 align-[-0.37em]',
verificationStatus === 'VERIFICATION_FAILED' && 'pr-0',
statusIcon.classNames.icon
)}
/>,
verificationStatus === 'VERIFICATION_FAILED' && (
<span class="text-sm font-bold text-red-500">SCAM</span>
),
]}
</Tooltip>
)
}

View File

@@ -304,9 +304,16 @@ const {
/>
</div>
{
options.attributesByCategory.map(({ category, attributes }) => (
options.attributesByCategory.map(({ categoryInfo, attributes }) => (
<fieldset class="min-w-0">
<legend class="font-title mb-0.5 text-xs tracking-wide text-white">{category}</legend>
<legend class="font-title mb-0.5 inline-flex items-center gap-1 text-[0.8125rem] tracking-wide text-white uppercase">
<Icon
name={categoryInfo.icon}
class={cn('size-4 shrink-0 opacity-80', categoryInfo.classNames.icon)}
aria-hidden="true"
/>
{categoryInfo.label}
</legend>
<ul class="[:not(:has(~_.peer:checked))]:[&>li:not([data-show-always])]:hidden">
{attributes.map((attribute) => {
@@ -371,11 +378,9 @@ const {
</label>
<span
class="bg-night-400 border-night-500 pointer-events-none block h-4 w-px border-y peer-checked/no:w-[0.5px] peer-checked/yes:w-[0.5px]"
class="bg-night-400 border-night-500 before:bg-night-400 before:border-night-600 pointer-events-none block h-4 w-px border-y peer-checked/no:w-[0.5px] peer-checked/yes:w-[0.5px] before:h-full before:w-px before:border-y-2"
aria-hidden="true"
>
<span class="bg-night-400 border-night-600 block h-full w-px border-y-2" />
</span>
/>
<label
for={noId}
@@ -398,8 +403,8 @@ const {
aria-hidden="true"
>
<Icon
name={attribute.info.icon}
class={cn('mr-2 size-3 shrink-0 opacity-80', attribute.info.classNames.icon)}
name={attribute.typeInfo.icon}
class={cn('mr-2 size-3 shrink-0 opacity-80', attribute.typeInfo.classNames.icon)}
aria-hidden="true"
/>
<span class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap">
@@ -413,8 +418,8 @@ const {
aria-hidden="true"
>
<Icon
name={attribute.info.icon}
class={cn('mr-2 size-3 shrink-0 opacity-100', attribute.info.classNames.icon)}
name={attribute.typeInfo.icon}
class={cn('mr-2 size-3 shrink-0 opacity-100', attribute.typeInfo.classNames.icon)}
aria-hidden="true"
/>
<span class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap">
@@ -432,18 +437,18 @@ const {
<>
<input
type="checkbox"
id={`show-more-attributes-${category}`}
id={`show-more-attributes-${categoryInfo.slug}`}
class="peer sr-only"
hx-preserve
/>
<label
for={`show-more-attributes-${category}`}
for={`show-more-attributes-${categoryInfo.slug}`}
class="peer-focus-visible:ring-offset-night-700 mt-2 block cursor-pointer rounded-sm text-sm text-green-500 peer-checked:hidden peer-focus-visible:ring-2 peer-focus-visible:ring-blue-500 peer-focus-visible:ring-offset-2"
>
+ Show more
</label>
<label
for={`show-more-attributes-${category}`}
for={`show-more-attributes-${categoryInfo.slug}`}
class="peer-focus-visible:ring-offset-night-700 mt-2 hidden cursor-pointer rounded-sm text-sm text-green-500 peer-checked:block peer-focus-visible:ring-2 peer-focus-visible:ring-blue-500 peer-focus-visible:ring-offset-2"
>
- Show less

View File

@@ -1,9 +1,11 @@
---
import { Icon } from 'astro-icon/components'
import { uniq } from 'lodash-es'
import { verificationStatusesByValue } from '../constants/verificationStatus'
import { cn } from '../lib/cn'
import { pluralize } from '../lib/pluralize'
import { createPageUrl } from '../lib/urls'
import { createPageUrl, urlWithParams } from '../lib/urls'
import Button from './Button.astro'
import ServiceCard from './ServiceCard.astro'
@@ -20,6 +22,8 @@ type Props = HTMLAttributes<'div'> & {
sortSeed?: string
filters: ServicesFiltersObject
includeScams: boolean
countIfIncludingCommunity: number | null
inlineIcons?: boolean
}
const {
@@ -32,6 +36,8 @@ const {
class: className,
filters,
includeScams,
countIfIncludingCommunity,
inlineIcons,
...divProps
} = Astro.props
@@ -46,34 +52,68 @@ const hasSomeCommunityContributed = !!services?.some((service) =>
)
const totalPages = Math.ceil(total / pageSize) || 1
const urlIfIncludingCommunity = urlWithParams(Astro.url, {
verification: uniq([
...filters.verification.map((v) => verificationStatusesByValue[v].slug),
verificationStatusesByValue.COMMUNITY_CONTRIBUTED.slug,
]),
})
const extraIfIncludingCommunity = Math.max(0, (countIfIncludingCommunity ?? 0) - (services?.length ?? 0))
---
<div {...divProps} class={cn('flex-1', className)}>
<div class="mb-6 flex items-center justify-between">
<div class="flex items-center justify-between">
<span class="text-day-500 text-sm">
{total.toLocaleString()}
{pluralize('result', total)}
{
extraIfIncludingCommunity > 0 && (
<Button
as="a"
href={urlIfIncludingCommunity}
label={`Include +${extraIfIncludingCommunity.toLocaleString()} community contributed`}
size="sm"
class="ml-6 align-[-0.15em]"
icon="ri:search-line"
inlineIcon={inlineIcons}
/>
)
}
<span
id="search-indicator"
class="htmx-request:opacity-100 text-white opacity-0 transition-opacity duration-500"
>
<Icon name="ri:loader-4-line" class="inline-block size-4 animate-spin" />
<Icon name="ri:loader-4-line" class="inline-block size-4 animate-spin" is:inline={inlineIcons} />
Loading...
</span>
</span>
<Button as="a" href="/service-suggestion/new" label="Add service" icon="ri:add-line" />
<Button
as="a"
href="/service-suggestion/new"
label="Add service"
icon="ri:add-line"
inlineIcon={inlineIcons}
/>
</div>
{
hasScams && hasCommunityContributed && (
<div class="font-title mb-6 rounded-lg border border-red-500/30 bg-red-950 px-3 py-2 text-sm text-pretty text-red-500">
<Icon name="ri:alert-fill" class="inline-block size-4 shrink-0 align-[-0.2em] text-red-500" />
<div class="font-title mt-2 rounded-lg bg-red-900/50 px-3 py-2 text-sm text-pretty text-red-400">
<Icon
name="ri:alert-fill"
class="inline-block size-4 shrink-0 align-[-0.2em] text-red-500"
is:inline={inlineIcons}
/>
<Icon
name="ri:question-line"
class="mr-1 inline-block size-4 shrink-0 align-[-0.2em] text-yellow-500"
class="mr-1 inline-block size-4 shrink-0 align-[-0.2em] text-yellow-400"
is:inline={inlineIcons}
/>
Results {hasSomeScam || hasSomeCommunityContributed ? 'include' : 'may include'} SCAMS or
Results {hasSomeScam || hasSomeCommunityContributed ? 'include' : 'may include'} SCAMs or
community-contributed services.
</div>
)
@@ -81,8 +121,12 @@ const totalPages = Math.ceil(total / pageSize) || 1
{
hasScams && !hasCommunityContributed && (
<div class="font-title mb-6 rounded-lg border border-red-500/30 bg-red-950 px-3 py-2 text-sm text-pretty text-red-500">
<Icon name="ri:alert-fill" class="mr-1 inline-block size-4 shrink-0 align-[-0.2em] text-red-500" />
<div class="font-title mt-2 rounded-lg bg-red-900/50 px-3 py-2 text-sm text-pretty text-red-400">
<Icon
name="ri:alert-fill"
class="mr-1 inline-block size-4 shrink-0 align-[-0.2em] text-red-500"
is:inline={inlineIcons}
/>
Results {hasSomeScam ? 'include' : 'may include'} SCAM services
</div>
)
@@ -90,10 +134,11 @@ const totalPages = Math.ceil(total / pageSize) || 1
{
!hasScams && hasCommunityContributed && (
<div class="font-title mb-6 rounded-lg border border-yellow-500/30 bg-yellow-950 px-3 py-2 text-sm text-pretty text-yellow-500">
<div class="font-title mt-2 rounded-lg bg-yellow-600/30 px-3 py-2 text-sm text-pretty text-yellow-200">
<Icon
name="ri:question-line"
class="mr-1 inline-block size-4 shrink-0 align-[-0.2em] text-yellow-500"
class="mr-1 inline-block size-4 shrink-0 align-[-0.2em] text-yellow-400"
is:inline={inlineIcons}
/>
Results {hasSomeCommunityContributed ? 'include' : 'may include'} unverified community-contributed
services, some might be scams.
@@ -103,26 +148,37 @@ const totalPages = Math.ceil(total / pageSize) || 1
{
!services || services.length === 0 ? (
<div class="sticky top-20 flex flex-col items-center justify-center rounded-lg border border-green-500/30 bg-black/40 p-12 text-center">
<Icon name="ri:emotion-sad-line" class="mb-4 size-16 text-green-500/50" />
<div class="sticky top-20 mt-6 flex flex-col items-center justify-center py-12 text-center">
<Icon name="ri:emotion-sad-line" class="mb-4 size-16 text-green-500/50" is:inline={inlineIcons} />
<h3 class="font-title mb-3 text-xl text-green-500">No services found</h3>
<p class="text-day-400">Try adjusting your filters to find more services</p>
<a
href={Astro.url.pathname}
class={cn(
'bg-night-800 font-title mt-4 rounded-md px-4 py-2 text-sm tracking-wider text-white uppercase',
hasDefaultFilters && 'hidden'
<div class="mt-4 flex justify-center gap-2">
{!hasDefaultFilters && (
<Button
as="a"
href={Astro.url.pathname}
label="Clear filters"
icon="ri:close-line"
inlineIcon={inlineIcons}
/>
)}
>
Clear filters
</a>
{extraIfIncludingCommunity > 0 && (
<Button
as="a"
href={urlIfIncludingCommunity}
label={`Show ${extraIfIncludingCommunity.toLocaleString()} community contributed`}
icon="ri:search-line"
inlineIcon={inlineIcons}
/>
)}
</div>
</div>
) : (
<>
<div class="grid grid-cols-1 gap-4 sm:gap-6 md:grid-cols-[repeat(auto-fill,minmax(calc(var(--spacing)*80),1fr))]">
<div class="mt-6 grid grid-cols-1 gap-4 sm:gap-6 md:grid-cols-[repeat(auto-fill,minmax(calc(var(--spacing)*80),1fr))]">
{services.map((service, i) => (
<ServiceCard
inlineIcons
inlineIcons={inlineIcons}
service={service}
data-hx-search-results-card
{...(i === services.length - 1 && currentPage < totalPages
@@ -140,7 +196,11 @@ const totalPages = Math.ceil(total / pageSize) || 1
<div class="no-js:hidden mt-8 flex justify-center" id="infinite-scroll-indicator">
<div class="htmx-request:opacity-100 flex items-center gap-2 opacity-0 transition-opacity duration-500">
<Icon name="ri:loader-4-line" class="size-8 animate-spin text-green-500" />
<Icon
name="ri:loader-4-line"
class="size-8 animate-spin text-green-500"
is:inline={inlineIcons}
/>
Loading more services...
</div>
</div>