Skip to content

Commit 15ef016

Browse files
committed
better documentation
1 parent 64095f4 commit 15ef016

1 file changed

Lines changed: 24 additions & 15 deletions

File tree

static/sass/_snapcraft_snap-details.scss

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,30 +111,39 @@
111111
container: pkgname / inline-size;
112112

113113
&__name {
114-
--length: 40; // default value, it should be overridden via inline styles on the element
115-
--fs-ratio: 1.765; // height/width (1rem/1ch) ratio measured in the browser
116-
// we take the full width of the container and divide it by the number of characters in the
117-
// package name (+2 to account for the parentheses): this is the horizontal space that each
118-
// character has on average; we multiply this by the fs-ratio to get the font size
114+
// package name string length; 40 is the maximum length the store backend
115+
// supports and this is just a default value, it should be overridden via inline styles on
116+
// the element
117+
--length: 40;
118+
119+
// font size/character width (1rem/1ch) ratio, a magic number
120+
// measured in the browser
121+
--fs-width-ratio: 1.77;
122+
123+
// we take the full width of the container (100cqw) and divide it by the number of
124+
// characters in the package name (+2 to account for the parentheses): this is the horizontal
125+
// space that each character will use on average; we multiply this by the font size/character
126+
// width ratio to get the font size
119127
--target-font-size: calc(
120-
(100cqw / (2 + var(--length))) * var(--fs-ratio)
128+
(100cqw / (2 + var(--length))) * var(--fs-width-ratio)
121129
);
122130

123-
// we limit the font size to the smallest and largest available sizes
124-
--max-font-size: #{map-get($settings-text-h1-mobile, font-size)}rem; // size of the title
125-
--min-font-size: #{map-get($settings-text-h5-mobile, font-size)}rem; // smallest size we allow
131+
// we limit the actual font size value to the smallest and largest heading font sizes
132+
--font-size: clamp(
133+
var(--min-font-size),
134+
var(--target-font-size),
135+
var(--max-font-size)
136+
);
137+
--min-font-size: #{map-get($settings-text-h6-mobile, font-size)}rem;
138+
--max-font-size: #{map-get($settings-text-h1-mobile, font-size)}rem;
126139

127140
@media (min-width: $breakpoint-heading-threshold) {
128-
--min-font-size: #{map-get($settings-text-h5, font-size)}rem;
141+
--min-font-size: #{map-get($settings-text-h6, font-size)}rem;
129142
--max-font-size: #{map-get($settings-text-h1, font-size)}rem;
130143
}
131144

132145
display: inline-block;
133-
font-size: clamp(
134-
var(--min-font-size),
135-
var(--target-font-size),
136-
var(--max-font-size)
137-
);
146+
font-size: var(--font-size);
138147
white-space: nowrap;
139148

140149
.p-tooltip__message {

0 commit comments

Comments
 (0)