about summary refs log tree commit diff
path: root/src/components/dialogs/nuxs/NeueTypography.tsx
blob: f160c877430626ba47b8d7529337ffd68138cfad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import React from 'react'
import {View} from 'react-native'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'

import {AppearanceToggleButtonGroup} from '#/screens/Settings/AppearanceSettings'
import {atoms as a, useAlf, useTheme} from '#/alf'
import * as Dialog from '#/components/Dialog'
import {useNuxDialogContext} from '#/components/dialogs/nuxs'
import {Divider} from '#/components/Divider'
import {TextSize_Stroke2_Corner0_Rounded as TextSize} from '#/components/icons/TextSize'
import {TitleCase_Stroke2_Corner0_Rounded as Aa} from '#/components/icons/TitleCase'
import {Text} from '#/components/Typography'

export function NeueTypography() {
  const t = useTheme()
  const {_} = useLingui()
  const nuxDialogs = useNuxDialogContext()
  const control = Dialog.useDialogControl()
  const {fonts} = useAlf()

  Dialog.useAutoOpen(control, 3e3)

  const onClose = React.useCallback(() => {
    nuxDialogs.dismissActiveNux()
  }, [nuxDialogs])

  const onChangeFontFamily = React.useCallback(
    (values: string[]) => {
      const next = values[0] === 'system' ? 'system' : 'theme'
      fonts.setFontFamily(next)
    },
    [fonts],
  )

  const onChangeFontScale = React.useCallback(
    (values: string[]) => {
      const next = values[0] || ('0' as any)
      fonts.setFontScale(next)
    },
    [fonts],
  )

  return (
    <Dialog.Outer control={control} onClose={onClose}>
      <Dialog.Handle />

      <Dialog.ScrollableInner label={_(msg`Introducing new font settings`)}>
        <View style={[a.gap_xl]}>
          <View style={[a.gap_md]}>
            <Text style={[a.text_3xl, a.font_heavy]}>
              <Trans>New font settings </Trans>
            </Text>
            <Text style={[a.text_lg, a.leading_snug, {maxWidth: 400}]}>
              <Trans>
                We're introducing a new theme font, along with adjustable font
                sizing.
              </Trans>
            </Text>
            <Text
              style={[a.text_sm, a.leading_snug, t.atoms.text_contrast_medium]}>
              <Trans>
                You can adjust these in your Appearance Settings later.
              </Trans>
            </Text>
          </View>

          <Divider />

          <View style={[a.gap_lg]}>
            <AppearanceToggleButtonGroup
              title={_(msg`Font`)}
              description={_(
                msg`For the best experience, we recommend using the theme font.`,
              )}
              icon={Aa}
              items={[
                {
                  label: _(msg`System`),
                  name: 'system',
                },
                {
                  label: _(msg`Theme`),
                  name: 'theme',
                },
              ]}
              values={[fonts.family]}
              onChange={onChangeFontFamily}
            />

            <AppearanceToggleButtonGroup
              title={_(msg`Font size`)}
              icon={TextSize}
              items={[
                {
                  label: _(msg`Smaller`),
                  name: '-1',
                },
                {
                  label: _(msg`Default`),
                  name: '0',
                },
                {
                  label: _(msg`Larger`),
                  name: '1',
                },
              ]}
              values={[fonts.scale]}
              onChange={onChangeFontScale}
            />
          </View>
        </View>

        <Dialog.Close />
      </Dialog.ScrollableInner>
    </Dialog.Outer>
  )
}