Skip to content

Commit 274f974

Browse files
committed
スロットにも 🈟 🈞 🈡 アイコンを
1 parent 137cfea commit 274f974

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

src/components/slot-item/title.tsx

+17-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { useMemo } from 'react'
44
import { Link, cn } from '@nextui-org/react'
55
import { useOverflowDetector } from 'react-detectable-overflow'
66

7+
import { ProgramIcons } from '@/entrypoints/popup/SidePane/JikkyoEpgSelector/Program'
8+
9+
const programIconsRegExp = /^(?:(?:🈞|🈟|🈡)\s?)+/
10+
711
export type TitleProps = {
812
type: StateSlotDetail['type']
913
infoId: StateSlotDetail['info']['id']
@@ -35,6 +39,16 @@ export const Title: React.FC<TitleProps> = ({
3539
return new URL(infoId, baseUrl)
3640
}, [type, infoId])
3741

42+
const icon = useMemo(() => {
43+
const prefix = infoTitle.match(programIconsRegExp)?.[0]
44+
45+
return {
46+
revival: prefix?.includes('🈞'),
47+
new: prefix?.includes('🈟'),
48+
last: prefix?.includes('🈡'),
49+
}
50+
}, [infoTitle])
51+
3852
const title = (
3953
<span
4054
className={cn(
@@ -44,7 +58,9 @@ export const Title: React.FC<TitleProps> = ({
4458
title={overflow ? infoTitle : undefined}
4559
ref={ref}
4660
>
47-
{infoTitle}
61+
<ProgramIcons icon={icon} />
62+
63+
<span>{infoTitle.replace(programIconsRegExp, '')}</span>
4864
</span>
4965
)
5066

src/entrypoints/popup/SidePane/JikkyoEpgSelector/Program.tsx

+14-14
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,32 @@ const programIcon = tv({
3434
],
3535
variants: {
3636
icon: {
37-
new: 'bg-orange-500 dark:bg-orange-300',
3837
revival: 'bg-blue-500 dark:bg-blue-300',
38+
new: 'bg-orange-500 dark:bg-orange-300',
3939
last: 'bg-red-500 dark:bg-red-300',
4040
},
4141
},
4242
})
4343

44-
type ProgramIconsProps = {
44+
export type ProgramIconsProps = {
4545
icon: Partial<EPGv2Program['icon']>
4646
}
4747

48-
const ProgramIcons: React.FC<ProgramIconsProps> = ({ icon }) => {
48+
export const ProgramIcons: React.FC<ProgramIconsProps> = ({ icon }) => {
4949
return (
5050
<>
51-
{icon.new && (
52-
<span className={programIcon({ icon: 'new' })} title="新番組">
53-
54-
</span>
55-
)}
56-
5751
{icon.revival && (
5852
<span className={programIcon({ icon: 'revival' })} title="再放送">
5953
6054
</span>
6155
)}
6256

57+
{icon.new && (
58+
<span className={programIcon({ icon: 'new' })} title="新番組">
59+
60+
</span>
61+
)}
62+
6363
{icon.last && (
6464
<span className={programIcon({ icon: 'last' })} title="最終回">
6565
@@ -69,12 +69,12 @@ const ProgramIcons: React.FC<ProgramIconsProps> = ({ icon }) => {
6969
)
7070
}
7171

72-
type ProgramContentProps = {
72+
export type ProgramContentProps = {
7373
program: EPGProgram
7474
bgColor: [light: string, dark: string]
7575
}
7676

77-
const ProgramContent: React.FC<ProgramContentProps> = ({
77+
export const ProgramContent: React.FC<ProgramContentProps> = ({
7878
program,
7979
bgColor,
8080
}) => {
@@ -150,12 +150,12 @@ const ProgramContent: React.FC<ProgramContentProps> = ({
150150
)
151151
}
152152

153-
type ProgramPopoverProps = {
153+
export type ProgramPopoverProps = {
154154
tverChId: EPGContent['tverChId']
155155
program: EPGProgram
156156
}
157157

158-
const ProgramPopover: React.FC<ProgramPopoverProps> = ({
158+
export const ProgramPopover: React.FC<ProgramPopoverProps> = ({
159159
tverChId,
160160
program,
161161
}) => {
@@ -170,8 +170,8 @@ const ProgramPopover: React.FC<ProgramPopoverProps> = ({
170170
const id = `${tverToJikkyoChId(tverChId)}:${startAt}-${endAt}`
171171

172172
const slotTitle = [
173-
icon.new && '🈟',
174173
icon.revival && '🈞',
174+
icon.new && '🈟',
175175
icon.last && '🈡',
176176

177177
normalize(description).includes(normalize(title))

src/utils/api/programToSlotDetail.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const programToSlotDetail = (
4949
status: 'pending',
5050
info: {
5151
id: program.TID,
52-
title: `${flags[0] ?? ''} ${title}`.trim(),
52+
title: [...flags, title].join(' ').trim(),
5353
duration: (endtime - starttime) / 1000,
5454
date: [starttime, endtime],
5555
count: {

0 commit comments

Comments
 (0)