Skip to content

Commit

Permalink
Make work title font sizes more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiriVulpes committed Jan 29, 2025
1 parent db2f7bc commit a65ff29
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ui/component/Work.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Work = Component.Builder((component, work: WorkData & Partial<WorkFull>, a
block.title
.style('work-name')
.text.set(work.name)
.setResizeRange(32, FormInputLengths.value?.work.name)
.setResizeRange(32, Math.min(FormInputLengths.value?.work.name ?? Infinity, 128))

if (author)
block.description
Expand Down
3 changes: 1 addition & 2 deletions src/ui/component/core/Heading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ const Heading = Component.Builder('h1', (component): Heading => {

const length = text?.length ?? 0
const t = 1 - Maths.clamp1(Maths.unlerp(resizeRange.minLength, resizeRange.maxLength, length))
const size = Maths.lerp(0.5, 1, t)
textWrapper.style.setProperty('font-size', `${size}em`)
textWrapper.style.setProperty('--font-size-multiplier', `${t}`)
})

component.tabIndex('programmatic')
Expand Down
1 change: 1 addition & 0 deletions style/component/core/heading.chiri
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
&-text:
%block
%padding-bottom-1
font-size: calc(${font-size-min: 1em} + ${font-size-multiplier: 1} * (${font-size-max: 1em} - ${font-size-min: 1em}))
line-height: 1.2em

#dec slant = 0.05
Expand Down
30 changes: 30 additions & 0 deletions style/mixins.chiri
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,33 @@

%width-clamp-content: max-width: #{content-width}
%width-content: width: #{content-width}

#do:
#list!dec font-sizes = [
0.6
0.8
0.9
1.0
1.2
1.5
1.8
2.4

#list!dec font-size-mins = [
0.6
0.8
0.9
1.0
1.1
1.1
1.2
1.2

#each in font-sizes as var i, var font-size:
%font-#{i}:
$font-size-base: #{font-size}rem
$font-size: round(calc($font-size-base / $font-scale-factor), 1px)
$font-scaling: #{font-size}
font-size: $font-size

$font-size-min: #{font-size-mins[i]}rem

0 comments on commit a65ff29

Please sign in to comment.