Skip to content

Commit 887fad2

Browse files
authored
feat: BCP/etc in RFC Card (left) (#95)
* feat: bcp/etc in card (left) * feat: 'part of' * feat: BCP/etc formatting * chore: refactoring rfc.ts into multiple files. New RfcCommon type to unify Rfc and TypeSense data structures * chore: refactor more out of rfc.ts * chore: linting * chore: more RFCCommon refactoring, especially subseries * chore: refactoring / tidy up of rfc parsing code * chore: parse rfc status slug tests * feat: bcp/etc aligned left after RFC Card number * chore: removing stories that Histoire can't compile * chore: linting
1 parent 77307d9 commit 887fad2

36 files changed

+958
-578
lines changed
Binary file not shown.
Binary file not shown.

client/components/Card.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
]"
77
>
88
<div :class="props.containerClass">
9-
<Heading :level="props.headingLevel">
9+
<Heading :level="props.headingLevel" class="text-[22px]">
1010
<NuxtLink
1111
:to="props.href"
1212
:class="[
13-
'block text-[22px] font-bold text-blue-300 dark:text-blue-100 print:text-black no-underline focus:underline hover:underline group',
13+
'font-bold text-blue-300 dark:text-blue-100 print:text-black no-underline focus:underline hover:underline group',
1414
props.hasCoverLink &&
1515
`before:absolute before:content-[\'\'] before:inset-0 before:transition-all dark:before:shadow-slate-700 hover:before:shadow-xl focus:before:shadow-xl dark:hover:before:shadow-[0_0px_40px_20px_#00101c] ${
1616
/* this is only a template string so I can write an inline comment:
@@ -34,6 +34,7 @@
3434
]"
3535
/>
3636
</NuxtLink>
37+
<slot name="afterHeadingTitle"></slot>
3738
</Heading>
3839
<slot />
3940
</div>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<template>
2+
<Story title="RFC Card">
3+
<RFCCard :rfc="rfcCommon" heading-level="3" />
4+
</Story>
5+
</template>
6+
7+
<script setup lang="ts">
8+
import { rfcToRfcCommon } from '~/utilities/rfc-converters'
9+
import { exampleRfc } from '~/utilities/rfc.mocks'
10+
11+
const rfcCommon = rfcToRfcCommon(exampleRfc)
12+
</script>

client/components/RFCCard.story.vue

Lines changed: 0 additions & 9 deletions
This file was deleted.

client/components/RFCCard.vue

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,33 @@
99
: 'end'
1010
"
1111
:class="props.showAbstract && props.rfc.abstract ? 'lg:flex' : undefined"
12-
:default-slot-class="
13-
props.showAbstract && props.rfc.abstract ? 'pr-4' : 'ff'
14-
"
12+
:default-slot-class="props.showAbstract && props.rfc.abstract ? 'pr-4' : ''"
1513
:aside-slot-class="
1614
props.showAbstract && props.rfc.abstract ?
1715
'flex-1 lg:w-1/2 xl:w-3/5 border-l pl-12 pr-4'
1816
: undefined
1917
"
2018
>
2119
<template #headingTitle>
22-
<component :is="formatTitle(`rfc${props.rfc.number}`)" />
20+
<component :is="formatTitleAsVNode(`rfc${props.rfc.number}`)" />
21+
</template>
22+
<template #afterHeadingTitle>
23+
<span v-if="props.rfc.subseries">
24+
<span>: </span>
25+
<NuxtLink
26+
to="/"
27+
class="relative z-50 no-underline hover:underline focus:underline px-2 py-3 rounded text-gray-700"
28+
:title="`part of ${props.rfc.subseries.type.toUpperCase()}${props.rfc.subseries.number}`"
29+
>
30+
<component
31+
:is="
32+
formatTitleAsVNode(
33+
`${props.rfc.subseries.type}${props.rfc.subseries.number}`
34+
)
35+
"
36+
/>
37+
</NuxtLink>
38+
</span>
2339
</template>
2440
<template #default>
2541
<RFCCardBody
@@ -50,14 +66,14 @@
5066
</template>
5167

5268
<script setup lang="ts">
53-
import type { Rfc } from '../generated/red-client'
5469
import { infoRfcPathBuilder } from '../utilities/url'
55-
import { formatTitle } from '~/utilities/rfc'
70+
import { formatTitleAsVNode } from '~/utilities/rfc'
71+
import type { RfcCommon } from '~/utilities/rfc'
5672
import { useResponsiveModeStore } from '~/stores/responsiveMode'
5773
import { parseHeadingLevel, type HeadingLevel } from '~/utilities/html'
5874
5975
type Props = {
60-
rfc: Rfc
76+
rfc: RfcCommon
6177
showAbstract?: boolean
6278
showTagDate?: boolean
6379
headingLevel?: HeadingLevel

client/components/RFCCardBody.vue

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
class="hidden lg:block print:block text-base text-gray-800 mt-1 dark:text-white"
2323
>
2424
<li v-if="isAprilFool" class="inline pr-2">
25-
<Icon name="fa6-solid:masks-theater" size="1em" class="text-violet-500 -mb-0.5" />
25+
<Icon
26+
name="fa6-solid:masks-theater"
27+
size="1em"
28+
class="text-violet-500 -mb-0.5"
29+
/>
2630
</li>
2731
<li v-for="(part, index) in list2" :key="index" class="inline">
2832
<GraphicsDiamond v-if="index > 0" class="align-middle" />{{ part }}
@@ -78,12 +82,12 @@
7882

7983
<script setup lang="ts">
8084
import { DateTime } from 'luxon'
81-
import type { Rfc, RfcMetadata } from '../generated/red-client'
8285
import { infoRfcPathBuilder } from '../utilities/url'
83-
import { formatTitlePlaintext } from '~/utilities/rfc'
86+
import type { RfcCommon } from '~/utilities/rfc'
87+
import { formatTitlePlaintext } from '~/utilities/rfc-converters-utils'
8488
8589
type Props = {
86-
rfc: Rfc
90+
rfc: RfcCommon
8791
showAbstract?: boolean
8892
showTagDate?: boolean
8993
}
@@ -94,23 +98,32 @@ const isMobileAbstractOpen = ref<boolean>(false)
9498
9599
const abstractDomId = useId()
96100
97-
function formatAuthors(authors: Rfc['authors']): string {
101+
function formatAuthors(authors: RfcCommon['authors']): string {
98102
if (authors.length === 0) {
99103
return ''
100104
} else if (authors.length === 1) {
101105
return `${authors[0].name}`
102106
} else {
103-
return authors.slice(0, authors.length - 1).map(author => author.name).join(', ') + ` and ${authors.at(-1)?.name}`
107+
return (
108+
authors
109+
.slice(0, authors.length - 1)
110+
.map((author) => author.name)
111+
.join(', ') + ` and ${authors.at(-1)?.name}`
112+
)
104113
}
105114
}
106115
107116
function formatDate(isoDate: string): string {
108117
const datetime = DateTime.fromISO(isoDate)
109-
return datetime.toLocaleString({ month: 'long', year: 'numeric', ...isAprilFool.value && { day: 'numeric' } })
118+
return datetime.toLocaleString({
119+
month: 'long',
120+
year: 'numeric',
121+
...(isAprilFool.value && { day: 'numeric' })
122+
})
110123
}
111124
112125
function formatObsoletedBy(
113-
obsoletedBy: RfcMetadata['obsoleted_by']
126+
obsoletedBy: RfcCommon['obsoleted_by']
114127
): VNode | undefined {
115128
if (!obsoletedBy || obsoletedBy.length === 0) return undefined
116129
@@ -144,20 +157,21 @@ const obsoletedBy = computed(() => {
144157
return formatObsoletedBy(props.rfc.obsoleted_by)
145158
})
146159
147-
const list1 = computed(() => [
148-
formatAuthors(props.rfc.authors)
149-
])
160+
const list1 = computed(() => [formatAuthors(props.rfc.authors)])
150161
151-
const list2 = computed(() => [
152-
formatDate(props.rfc.published),
153-
props.rfc.stream?.name,
154-
props.rfc.area?.name
155-
].filter(Boolean) as string[])
162+
const list2 = computed(
163+
() =>
164+
[
165+
formatDate(props.rfc.published),
166+
props.rfc.stream?.name,
167+
props.rfc.area?.name
168+
].filter(Boolean) as string[]
169+
)
156170
157171
const tagText = computed(() => {
158172
const tagText = []
159-
if (props.rfc.status.name) {
160-
tagText.push(props.rfc.status.name)
173+
if (props.rfc.status) {
174+
tagText.push(props.rfc.status)
161175
}
162176
const datetime = DateTime.fromISO(props.rfc.published)
163177
const relativeCalendar = datetime.toRelativeCalendar()
@@ -169,6 +183,6 @@ const tagText = computed(() => {
169183
170184
const isAprilFool = computed(() => {
171185
const datetime = DateTime.fromISO(props.rfc.published)
172-
return (datetime.month === 4 && datetime.day === 1)
186+
return datetime.month === 4 && datetime.day === 1
173187
})
174188
</script>

client/components/RFCCardCompact.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
container-class="flex"
1313
>
1414
<template #headingTitle>
15-
<component :is="formatTitle(`rfc${props.rfc.number}`)" />
15+
<component :is="formatTitleAsVNode(`rfc${props.rfc.number}`)" />
1616
</template>
1717
<p
1818
class="ml-4 pl-4 border-l-1 border-gray-300 text-base text-blue-900 dark:text-white flex items-center"
@@ -23,14 +23,14 @@
2323
</template>
2424

2525
<script setup lang="ts">
26-
import type { Rfc } from '../generated/red-client'
2726
import { infoRfcPathBuilder } from '../utilities/url'
28-
import { formatTitle } from '~/utilities/rfc'
27+
import { formatTitleAsVNode } from '~/utilities/rfc'
28+
import type { RfcCommon } from '~/utilities/rfc'
2929
import { useResponsiveModeStore } from '~/stores/responsiveMode'
3030
import type { HeadingLevel } from '~/utilities/html'
3131
3232
type Props = {
33-
rfc: Rfc
33+
rfc: RfcCommon
3434
headingLevel?: HeadingLevel
3535
}
3636

client/components/RFCCardDense.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"
2222
>
2323
<template #headingTitle>
24-
<component :is="formatTitle(`rfc${props.rfc.number}`)" />
24+
<component :is="formatTitleAsVNode(`rfc${props.rfc.number}`)" />
2525
</template>
2626
<template #default>
2727
<RFCCardBody
@@ -34,14 +34,14 @@
3434
</template>
3535

3636
<script setup lang="ts">
37-
import type { Rfc } from '../generated/red-client'
3837
import { infoRfcPathBuilder } from '../utilities/url'
39-
import { formatTitle } from '~/utilities/rfc'
38+
import { formatTitleAsVNode } from '~/utilities/rfc'
39+
import type { RfcCommon } from '~/utilities/rfc'
4040
import { useResponsiveModeStore } from '~/stores/responsiveMode'
4141
import type { HeadingLevel } from '~/utilities/html'
4242
4343
type Props = {
44-
rfc: Rfc
44+
rfc: RfcCommon
4545
showAbstract?: boolean
4646
showTagDate?: boolean
4747
headingLevel?: HeadingLevel

client/components/RFCCardSearchItem.vue

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)