mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-07 07:56:12 +02:00
feat: setup resource title & extract necessary helpers
This commit is contained in:
@@ -2,21 +2,12 @@ import styled, { css } from "styled-components"
|
|||||||
import {
|
import {
|
||||||
BASE_FONT_SIZE,
|
BASE_FONT_SIZE,
|
||||||
BASE_LINE_HEIGHT,
|
BASE_LINE_HEIGHT,
|
||||||
MODULAR_SCALE,
|
|
||||||
fontFamily,
|
fontFamily,
|
||||||
|
modularScale,
|
||||||
} from "../../design/typography"
|
} from "../../design/typography"
|
||||||
|
|
||||||
function modularFontSize(power: number) {
|
function modularScaleCSS(power: number) {
|
||||||
return BASE_FONT_SIZE * Math.pow(MODULAR_SCALE, power)
|
const { fontSize, lineHeight } = modularScale(power)
|
||||||
}
|
|
||||||
|
|
||||||
function modularScale(power: number) {
|
|
||||||
const fontSize = modularFontSize(power)
|
|
||||||
|
|
||||||
// attempt to fit line-height a little larger than font-size
|
|
||||||
const paddedLineHeight = fontSize * 1.1
|
|
||||||
const lineHeight =
|
|
||||||
paddedLineHeight - (paddedLineHeight % BASE_LINE_HEIGHT) + BASE_LINE_HEIGHT
|
|
||||||
|
|
||||||
return css`
|
return css`
|
||||||
font-size: ${fontSize}px;
|
font-size: ${fontSize}px;
|
||||||
@@ -53,26 +44,26 @@ export const MarkdownWrapper = styled.div`
|
|||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
${modularScale(6)};
|
${modularScaleCSS(6)};
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
${modularScale(5)};
|
${modularScaleCSS(5)};
|
||||||
}
|
}
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
${modularScale(4)};
|
${modularScaleCSS(4)};
|
||||||
}
|
}
|
||||||
|
|
||||||
h4 {
|
h4 {
|
||||||
${modularScale(3)};
|
${modularScaleCSS(3)};
|
||||||
}
|
}
|
||||||
|
|
||||||
h5 {
|
h5 {
|
||||||
${modularScale(2)};
|
${modularScaleCSS(2)};
|
||||||
}
|
}
|
||||||
|
|
||||||
h6 {
|
h6 {
|
||||||
${modularScale(1)};
|
${modularScaleCSS(1)};
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import styled from "styled-components"
|
import styled from "styled-components"
|
||||||
|
import { fontFamily, modularScale } from "../../design/typography"
|
||||||
|
|
||||||
export const ResourceHeaderWrapper = styled.div`
|
export const ResourceHeaderWrapper = styled.div`
|
||||||
border-bottom: 1px solid #dbdbdb;
|
border-bottom: 1px solid #dbdbdb;
|
||||||
@@ -11,7 +12,12 @@ export const Top = styled.div`
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
`
|
`
|
||||||
|
|
||||||
export const Title = styled.h1``
|
export const Title = styled.h1`
|
||||||
|
font-family: ${fontFamily.header};
|
||||||
|
font-size: ${modularScale(6).fontSize}px;
|
||||||
|
line-height: ${modularScale(6).lineHeight}px;
|
||||||
|
letter-spacing: -1.75px;
|
||||||
|
`
|
||||||
|
|
||||||
export const AuthorAvatars = styled.div`
|
export const AuthorAvatars = styled.div`
|
||||||
margin-right: 16px;
|
margin-right: 16px;
|
||||||
|
|||||||
@@ -5,6 +5,24 @@ export const BASE_FONT_SIZE = 18
|
|||||||
export const BASE_LINE_HEIGHT = 25
|
export const BASE_LINE_HEIGHT = 25
|
||||||
export const MODULAR_SCALE = 1.1487
|
export const MODULAR_SCALE = 1.1487
|
||||||
|
|
||||||
|
function modularFontSize(power: number) {
|
||||||
|
return BASE_FONT_SIZE * Math.pow(MODULAR_SCALE, power)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function modularScale(power: number) {
|
||||||
|
const fontSize = modularFontSize(power)
|
||||||
|
|
||||||
|
// attempt to fit line-height a little larger than font-size
|
||||||
|
const paddedLineHeight = fontSize * 1.1
|
||||||
|
const lineHeight =
|
||||||
|
paddedLineHeight - (paddedLineHeight % BASE_LINE_HEIGHT) + BASE_LINE_HEIGHT
|
||||||
|
|
||||||
|
return {
|
||||||
|
fontSize,
|
||||||
|
lineHeight,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const fontFamily = {
|
export const fontFamily = {
|
||||||
header: FONT_MONTSERRAT,
|
header: FONT_MONTSERRAT,
|
||||||
body: FONT_OXYGEN,
|
body: FONT_OXYGEN,
|
||||||
|
|||||||
Reference in New Issue
Block a user