Skip to content

Commit

Permalink
@0.2.7: header block supports byline
Browse files Browse the repository at this point in the history
  • Loading branch information
artemis-prime committed Feb 2, 2024
1 parent 58d4f77 commit 30f87e2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion pkgs/luxdefi-ui/blocks/components/heading-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,40 @@ const HeadingBlockComponent: React.FC<{
const heading = block as HeadingBlock

let Tag: React.ElementType = 'h3' // default
let BylineTag: React.ElementType = 'h5' // default: two levels below main

switch (heading.level) {
case 0: {
Tag = 'p'
BylineTag = 'p'
} break
case 1: {
Tag = 'h1'
BylineTag = 'h3'
} break
case 2: {
Tag = 'h2'
BylineTag = 'h4'
} break

case 4: {
Tag = 'h4'
BylineTag = 'h6'
} break
case 5: {
Tag = 'h5'
BylineTag = 'p'
} break
case 6: {
Tag = 'h6'
BylineTag = 'p'
} break
}

return <Tag className={className}>{heading.heading}</Tag>
return (<>
<Tag className={className}>{heading.heading}</Tag>
{heading.byline && (<BylineTag >{heading.byline}</BylineTag>)}
</>)
}

export default HeadingBlockComponent
1 change: 1 addition & 0 deletions pkgs/luxdefi-ui/blocks/def/heading-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type Block from './block'
interface HeadingBlock extends Block {
blockType: 'heading'
heading: string
byline?: string
level?: number
}

Expand Down
2 changes: 1 addition & 1 deletion pkgs/luxdefi-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@luxdefi/ui",
"version": "0.2.6",
"version": "0.2.7",
"description": "Library that contains shared UI primitives, styles, and core types",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand Down

0 comments on commit 30f87e2

Please sign in to comment.