66 * Side Public License, v 1.
77 */
88
9+ import { CSSProperties } from 'react' ;
910import { css } from '@emotion/react' ;
1011import { UseEuiTheme } from '../../services' ;
11- import { euiTextBreakWord } from '../../global_styling' ;
12+ import {
13+ euiTextBreakWord ,
14+ euiFontSizeFromScale ,
15+ euiLineHeightFromBaseline ,
16+ _EuiThemeFontScale ,
17+ _EuiThemeFontSizeMeasurement ,
18+ } from '../../global_styling' ;
19+ import { EuiTitleSize } from './title' ;
1220
21+ /**
22+ * Theme-specific scale settings
23+ */
24+ type _EuiThemeTitle = {
25+ fontSize : _EuiThemeFontScale ;
26+ lineHeight : _EuiThemeFontScale ;
27+ fontWeight ?: CSSProperties [ 'fontWeight' ] ; // Defaults to bold
28+ letterSpacing ?: string ; // Not currently used in Amsterdam, but may be used in future themes
29+ } ;
30+
31+ const amsterdamThemeTitles : {
32+ [ size in EuiTitleSize ] : _EuiThemeTitle ;
33+ } = {
34+ xxxs : {
35+ fontSize : 'xs' ,
36+ lineHeight : 'xs' ,
37+ } ,
38+ xxs : {
39+ fontSize : 's' ,
40+ lineHeight : 'm' ,
41+ } ,
42+ xs : {
43+ fontSize : 'm' ,
44+ lineHeight : 'm' ,
45+ } ,
46+ s : {
47+ fontSize : 'l' ,
48+ lineHeight : 'xl' ,
49+ } ,
50+ m : {
51+ fontSize : 'xl' ,
52+ lineHeight : 'xl' ,
53+ } ,
54+ l : {
55+ fontSize : 'xxl' ,
56+ lineHeight : 'xxl' ,
57+ } ,
58+ } ;
59+
60+ /**
61+ * Mixin
62+ */
63+ export const euiTitle = (
64+ scale : EuiTitleSize = 'm' ,
65+ euiTheme : UseEuiTheme [ 'euiTheme' ] ,
66+ measurement : _EuiThemeFontSizeMeasurement = 'rem'
67+ ) : {
68+ fontSize : CSSProperties [ 'fontSize' ] ;
69+ lineHeight : CSSProperties [ 'lineHeight' ] ;
70+ fontWeight : CSSProperties [ 'fontWeight' ] ;
71+ letterSpacing ?: CSSProperties [ 'letterSpacing' ] ;
72+ } => {
73+ // NOTE: For future themes, we can conditionally key off `euiTheme.themeName`
74+ // and conditionally switch our title settings.
75+ const title = amsterdamThemeTitles [ scale ] ;
76+
77+ return {
78+ fontSize : euiFontSizeFromScale ( title . fontSize , euiTheme , measurement ) ,
79+ lineHeight : euiLineHeightFromBaseline (
80+ title . lineHeight ,
81+ euiTheme ,
82+ measurement
83+ ) ,
84+ fontWeight : title . fontWeight || euiTheme . font . weight . bold ,
85+ letterSpacing : title . letterSpacing ,
86+ } ;
87+ } ;
88+
89+ /**
90+ * Styles
91+ */
1392export const euiTitleStyles = ( { euiTheme } : UseEuiTheme ) => ( {
1493 euiTitle : css `
1594 ${ euiTextBreakWord }
@@ -22,5 +101,23 @@ export const euiTitleStyles = ({ euiTheme }: UseEuiTheme) => ({
22101 uppercase : css `
23102 text-transform : uppercase;
24103 ` ,
25- // TODO: Sizes
104+ // Sizes
105+ xxxs : css `
106+ ${ euiTitle ( 'xxxs' , euiTheme ) }
107+ ` ,
108+ xxs : css `
109+ ${ euiTitle ( 'xxs' , euiTheme ) }
110+ ` ,
111+ xs : css `
112+ ${ euiTitle ( 'xs' , euiTheme ) }
113+ ` ,
114+ s : css `
115+ ${ euiTitle ( 's' , euiTheme ) }
116+ ` ,
117+ m : css `
118+ ${ euiTitle ( 'm' , euiTheme ) }
119+ ` ,
120+ l : css `
121+ ${ euiTitle ( 'l' , euiTheme ) }
122+ ` ,
26123} ) ;
0 commit comments