Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: listing metadata #541

Merged
merged 15 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/common/src/scss/components/_IconProfile.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.IconProfile {
width: 1em;
height: 1em;
}
4 changes: 4 additions & 0 deletions packages/common/src/scss/components/_IconSubject.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.IconSubject {
width: 1em;
height: 1em;
}
4 changes: 2 additions & 2 deletions packages/vue/lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import BaseModal from './../src/components/BaseModal/BaseModal.vue'
import BasePlaceholder from './../src/components/BasePlaceholder/BasePlaceholder.vue'
import BaseRadioGroup from './../src/components/BaseRadioGroup/BaseRadioGroup.vue'
import BaseSwimlane from './../src/components/BaseSwimlane/BaseSwimlane.vue'
import BaseTag from './../src/components/BaseTag/BaseTag.vue'
import BasePill from './../src/components/BasePill/BasePill.vue'
import BaseTimer from './../src/components/BaseTimer/BaseTimer.vue'
import BaseUnitToggle from './../src/components/BaseUnitToggle/BaseUnitToggle.vue'
import BaseVideo from './../src/components/BaseVideo/BaseVideo.vue'
Expand Down Expand Up @@ -248,7 +248,7 @@ export {
BasePlaceholder,
BaseRadioGroup,
BaseSwimlane,
BaseTag,
BasePill,
BaseTimer,
BaseUnitToggle,
BaseVideo,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import BaseTag from './BaseTag.vue'
import BasePill from './BasePill.vue'

export default {
title: 'Components/Base/BaseTag',
component: BaseTag,
title: 'Components/Base/BasePill',
component: BasePill,
argTypes: {
variant: {
type: { name: 'string', required: false },
Expand Down
54 changes: 54 additions & 0 deletions packages/vue/src/components/BasePill/BasePill.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<script setup lang="ts">
import { computed } from 'vue'
import type { Attributes } from './../../interfaces'
import { eduMetadataDictionary } from './../../constants'

// using borders to vertically center wonky font face
const variantMap: Attributes = {
primary: 'bg-primary border-primary',
secondary: 'bg-secondary border-secondary',
action: 'bg-action border-action'
}

const sizeMap: Attributes = {
sm: 'text-xs border-t-2 py-1 px-2.5',
md: 'text-xs lg:text-base border-t py-1.5 px-3.5',
lg: 'text-base lg:text-lg border-t pt-1.5 pb-1 px-5'
}

interface BasePillProps {
variant?: string
size?: string
contentType?: string
}

// define props
const props = withDefaults(defineProps<BasePillProps>(), {
variant: 'primary',
size: 'md',
contentType: undefined
})

const metadataType = computed(() => {
const validContentTypes = Object.keys(eduMetadataDictionary)
return props.contentType && validContentTypes.includes(props.contentType)
? props.contentType
: undefined
})
const metadataAttrs = computed(() => {
if (metadataType.value) {
return eduMetadataDictionary[metadataType.value]
}
return { variant: undefined, label: undefined }
})
</script>
<template>
<p
:class="`${variantMap[metadataAttrs.variant || props.variant]} ${sizeMap[props.size]}`"
class="ThemeVariantLight text-contrast-none inline-block text-white font-bold edu:font-extrabold rounded-full leading-tight m-0 uppercase print:border-none print:px-0"
>
<template v-if="metadataAttrs.label"> {{ metadataAttrs.label }} </template>
<template v-else> <slot /></template>
<span class="sr-only">.</span>
</p>
</template>
36 changes: 0 additions & 36 deletions packages/vue/src/components/BaseTag/BaseTag.vue

This file was deleted.

105 changes: 93 additions & 12 deletions packages/vue/src/components/BlockLinkCard/BlockLinkCard.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ export default {
component: BlockLinkCard,
tags: ['!autodocs'],
excludeStories: /.*Data$/,
decorators: [
() => ({
template: `<div id="storyDecorator" class="relative grid grid-cols-2 gap-3 lg:grid-cols-3"><story/></div>`
})
],
argTypes: {
size: {
control: {
type: 'select',
options: ['sm', 'md', 'lg']
}
},
headingLevel: {
description:
'Change the heading level for semantic markup. This does not affect the style of the heading.',
Expand Down Expand Up @@ -47,25 +48,39 @@ export const BlockLinkCardData = {
},
headingLevel: 'h2',
startDate: undefined,
endDate: undefined,
compact: false
endDate: undefined
}

export const BaseStory = {
name: 'Single Item',
decorators: [
() => ({
template: `<div id="storyDecorator" class="relative grid grid-cols-2 gap-3"><story/></div>`
})
],
args: {
...BlockLinkCardData
}
}

export const SingleItemCompactStyles = {
decorators: [
() => ({
template: `<div id="storyDecorator" class="relative grid grid-cols-2 gap-3"><story/></div>`
})
],
args: {
...BlockLinkCardData,
headingLevel: 'h2',
compact: true
size: 'sm'
}
}
export const Compact = {
decorators: [
() => ({
template: `<div id="storyDecorator" class="relative grid grid-cols-2 gap-3"><story/></div>`
})
],
name: 'Compact w/ Custom Props',
parameters: {
docs: {
Expand All @@ -89,16 +104,82 @@ export const Compact = {
alt: 'Alt text'
},
headingLevel: 'h2',
compact: true
size: 'sm'
}
}
export const EventItem = {
decorators: [
() => ({
template: `<div id="storyDecorator" class="relative grid grid-cols-2 gap-3"><story/></div>`
})
],
args: {
...BlockLinkCardData,
data: {
...BlockLinkCardData.data,
startDate: '2021-11-11T00:00:00-08:00',
endDate: '2021-11-11T23:59:59.999999-08:00'
page: {
...BlockLinkCardData.data,
__typename: 'EDUEventPage',
startDate: '2021-11-11',
startDatetime: '2021-11-11T00:00:00-08:00',
endDatetime: '2021-11-11T23:59:59.999999-08:00',
endDate: '2021-11-11',
ongoing: false,
eventType: 'Workshop'
}
}
}
}
export const EduExplainerArticle = {
decorators: [
() => ({
template: `<div id="storyDecorator" class="relative grid grid-cols-2 gap-3"><story/></div>`
})
],
args: {
...BlockLinkCardData,
data: {
page: {
__typename: 'EDUExplainerArticlePage',
...BlockLinkCardData.data,
primarySubject: {
subject: 'Engineering'
},
gradeLevels: [
{ gradeLevel: 'All Ages' },
{ gradeLevel: 'K' },
{ gradeLevel: '1' },
{ gradeLevel: '2' },
{ gradeLevel: '5' },
{ gradeLevel: '6' },
{ gradeLevel: '7' },
{ gradeLevel: '8' }
]
}
}
}
}
export const LargeEduExplainerArticle = {
args: {
...BlockLinkCardData,
size: 'lg',
data: {
page: {
__typename: 'EDUExplainerArticlePage',
...BlockLinkCardData.data,
primarySubject: {
subject: 'Engineering'
},
gradeLevels: [
{ gradeLevel: 'All Ages' },
{ gradeLevel: 'K' },
{ gradeLevel: '1' },
{ gradeLevel: '2' },
{ gradeLevel: '5' },
{ gradeLevel: '6' },
{ gradeLevel: '7' },
{ gradeLevel: '8' }
]
}
}
}
}
Loading
Loading