diff --git a/app/javascript/fonts/inter/LICENSE.txt b/app/javascript/fonts/inter/LICENSE.txt new file mode 100644 index 00000000000..9b2ca37b3ff --- /dev/null +++ b/app/javascript/fonts/inter/LICENSE.txt @@ -0,0 +1,92 @@ +Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION AND CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/app/javascript/fonts/inter/inter-italic.woff2 b/app/javascript/fonts/inter/inter-italic.woff2 new file mode 100644 index 00000000000..9a1ad2167a9 Binary files /dev/null and b/app/javascript/fonts/inter/inter-italic.woff2 differ diff --git a/app/javascript/fonts/inter/inter-regular.woff2 b/app/javascript/fonts/inter/inter-regular.woff2 new file mode 100644 index 00000000000..2bcd222ecfa Binary files /dev/null and b/app/javascript/fonts/inter/inter-regular.woff2 differ diff --git a/app/javascript/fonts/inter/inter-semibold-italic.woff2 b/app/javascript/fonts/inter/inter-semibold-italic.woff2 new file mode 100644 index 00000000000..d67d01c6c45 Binary files /dev/null and b/app/javascript/fonts/inter/inter-semibold-italic.woff2 differ diff --git a/app/javascript/fonts/inter/inter-semibold.woff2 b/app/javascript/fonts/inter/inter-semibold.woff2 new file mode 100644 index 00000000000..fbae113d285 Binary files /dev/null and b/app/javascript/fonts/inter/inter-semibold.woff2 differ diff --git a/app/javascript/fonts/syne/OFL.txt b/app/javascript/fonts/syne/OFL.txt new file mode 100644 index 00000000000..f410e51ceb9 --- /dev/null +++ b/app/javascript/fonts/syne/OFL.txt @@ -0,0 +1,93 @@ +Copyright 2017 The Syne Project Authors (https://gitlab.com/bonjour-monde/fonderie/syne-typeface) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/app/javascript/fonts/syne/syne-bold.woff2 b/app/javascript/fonts/syne/syne-bold.woff2 new file mode 100644 index 00000000000..e2c9861358c Binary files /dev/null and b/app/javascript/fonts/syne/syne-bold.woff2 differ diff --git a/app/javascript/inline/theme-selection.js b/app/javascript/inline/theme-selection.js index 680fbb23ec2..841dbc64366 100644 --- a/app/javascript/inline/theme-selection.js +++ b/app/javascript/inline/theme-selection.js @@ -21,4 +21,13 @@ updateColorScheme(); updateContrast(); + + const isRedesignEnabled = ( + window.localStorage.getItem('experiments')?.split(',') ?? [] + ).includes('redesign'); + + if (isRedesignEnabled) { + element.dataset.redesign = true; + } + })(document.documentElement); diff --git a/app/javascript/mastodon/components/_theme_playground/index.tsx b/app/javascript/mastodon/components/_theme_playground/index.tsx index efa2d540d26..cb3697764ab 100644 --- a/app/javascript/mastodon/components/_theme_playground/index.tsx +++ b/app/javascript/mastodon/components/_theme_playground/index.tsx @@ -54,7 +54,13 @@ export const ThemePlayground: React.FC = () => { -
Test 1 2 3
+
+

Home

+

Test 1 2 3

+

+ This is a bold statement! +

+
Hello World
); diff --git a/app/javascript/mastodon/components/_theme_playground/theme_playground.module.scss b/app/javascript/mastodon/components/_theme_playground/theme_playground.module.scss index bac775034ae..5c87d55a5b3 100644 --- a/app/javascript/mastodon/components/_theme_playground/theme_playground.module.scss +++ b/app/javascript/mastodon/components/_theme_playground/theme_playground.module.scss @@ -1,17 +1,34 @@ @use '@/styles/mastodon/mixins'; .wrapper { + // Override global body font variable because Storybook + // doesn't have the `data-redesign` html attribute + --font-body: Inter, sans-serif; + position: relative; display: grid; grid-template-columns: 250px 1fr; gap: var(--space-md); padding: var(--space-3xl); + font-family: Inter, sans-serif; font-size: var(--fs-lg); line-height: var(--lh-normal); overflow-wrap: break-word; color: var(--color-text-primary); background-color: var(--color-bg-blend); + h1 { + @include mixins.type-heading-lg; + } + + p { + @include mixins.type-body; + } + + strong { + font-weight: bold; + } + * { min-width: 0; } diff --git a/app/javascript/styles/application.scss b/app/javascript/styles/application.scss index bdbe8f067c4..16becc9b7aa 100644 --- a/app/javascript/styles/application.scss +++ b/app/javascript/styles/application.scss @@ -2,6 +2,8 @@ @use 'mastodon/mixins'; @use 'fonts/roboto'; @use 'fonts/roboto-mono'; +@use 'fonts/inter'; +@use 'fonts/syne'; @use 'mastodon/reset'; @use 'mastodon/tokens'; diff --git a/app/javascript/styles/entrypoints/mailer.scss b/app/javascript/styles/entrypoints/mailer.scss index cd1acb6a817..8ef00454998 100644 --- a/app/javascript/styles/entrypoints/mailer.scss +++ b/app/javascript/styles/entrypoints/mailer.scss @@ -1,4 +1,4 @@ -@use '../fonts/inter'; +@use '../fonts/inter-mailer'; body { accent-color: #6364ff; diff --git a/app/javascript/styles/fonts/inter-mailer.scss b/app/javascript/styles/fonts/inter-mailer.scss new file mode 100644 index 00000000000..816fc75b85a --- /dev/null +++ b/app/javascript/styles/fonts/inter-mailer.scss @@ -0,0 +1,8 @@ +@font-face { + font-family: Inter; + src: url('../../fonts/inter/inter-variable-font-slnt-wght.woff2') + format('woff2-variations'); + font-weight: 100 900; + font-style: normal; + mso-generic-font-family: swiss; +} diff --git a/app/javascript/styles/fonts/inter.scss b/app/javascript/styles/fonts/inter.scss index 816fc75b85a..3431277e3e2 100644 --- a/app/javascript/styles/fonts/inter.scss +++ b/app/javascript/styles/fonts/inter.scss @@ -1,8 +1,35 @@ +// Regular @font-face { font-family: Inter; - src: url('../../fonts/inter/inter-variable-font-slnt-wght.woff2') - format('woff2-variations'); - font-weight: 100 900; + src: url('../../fonts/inter/inter-regular.woff2') format('woff2'); + font-weight: 400; font-style: normal; - mso-generic-font-family: swiss; + font-display: swap; +} + +// Italic +@font-face { + font-family: Inter; + src: url('../../fonts/inter/inter-italic.woff2') format('woff2'); + font-weight: 400; + font-style: italic; + font-display: swap; +} + +// SemiBold (native 600, mapped to 700 so that `font-weight: bold` uses it) +@font-face { + font-family: Inter; + src: url('../../fonts/inter/inter-semibold.woff2') format('woff2'); + font-weight: 700; + font-style: normal; + font-display: swap; +} + +// SemiBold Italic (native 600, mapped to 700 so that `font-weight: bold` uses it) +@font-face { + font-family: Inter; + src: url('../../fonts/inter/inter-semibold-italic.woff2') format('woff2'); + font-weight: 700; + font-style: italic; + font-display: swap; } diff --git a/app/javascript/styles/fonts/syne.scss b/app/javascript/styles/fonts/syne.scss new file mode 100644 index 00000000000..7dadd110c27 --- /dev/null +++ b/app/javascript/styles/fonts/syne.scss @@ -0,0 +1,7 @@ +@font-face { + font-family: Syne; + src: url('../../fonts/syne/syne-bold.woff2') format('woff2'); + font-weight: 700; + font-style: normal; + font-display: swap; +} diff --git a/app/javascript/styles/mastodon/_mixins.scss b/app/javascript/styles/mastodon/_mixins.scss index 0a12333732a..1463a41733c 100644 --- a/app/javascript/styles/mastodon/_mixins.scss +++ b/app/javascript/styles/mastodon/_mixins.scss @@ -3,7 +3,7 @@ */ @mixin type-heading-lg { - // font-family: Syne; + font-family: var(--font-heading); font-size: var(--fs-3xl); font-weight: bold; line-height: var(--lh-tighter); @@ -11,7 +11,7 @@ } @mixin type-heading-md { - // font-family: Syne; + font-family: var(--font-heading); font-size: var(--fs-2xl); font-weight: bold; line-height: var(--lh-tighter); @@ -19,7 +19,7 @@ } @mixin type-heading-sm { - // font-family: Syne; + font-family: var(--font-heading); font-size: var(--fs-xl); font-weight: bold; line-height: var(--lh-tight); @@ -27,7 +27,7 @@ } @mixin type-body-lg { - // font-family: Inter; + font-family: var(--font-body); font-size: var(--fs-lg); font-weight: normal; line-height: var(--lh-normal); @@ -35,7 +35,7 @@ } @mixin type-body-strong { - // font-family: Inter; + font-family: var(--font-body); font-size: var(--fs-md); font-weight: bold; line-height: var(--lh-normal); @@ -43,7 +43,7 @@ } @mixin type-body { - // font-family: Inter; + font-family: var(--font-body); font-size: var(--fs-md); font-weight: normal; line-height: var(--lh-normal); @@ -51,7 +51,7 @@ } @mixin type-body-compact { - // font-family: Inter; + font-family: var(--font-body); font-size: var(--fs-sm); font-weight: normal; line-height: var(--lh-tight); @@ -59,7 +59,7 @@ } @mixin type-label-lg { - // font-family: Inter; + font-family: var(--font-body); font-size: var(--fs-sm); font-weight: bold; line-height: var(--lh-tight); @@ -67,7 +67,7 @@ } @mixin type-label-md { - // font-family: Inter; + font-family: var(--font-body); font-size: var(--fs-xs); font-weight: normal; line-height: var(--lh-tighter); @@ -75,7 +75,7 @@ } @mixin type-label-sm { - // font-family: Inter; + font-family: var(--font-body); font-size: var(--fs-2xs); font-weight: normal; line-height: var(--lh-tighter); @@ -83,7 +83,7 @@ } @mixin type-micro { - // font-family: 'JetBrains Mono'; + font-family: var(--font-monospace); font-size: var(--fs-3xs); font-weight: normal; line-height: var(--lh-tighter); diff --git a/app/javascript/styles/mastodon/_variables.scss b/app/javascript/styles/mastodon/_variables.scss index f0b12a373ff..c2317ac7f41 100644 --- a/app/javascript/styles/mastodon/_variables.scss +++ b/app/javascript/styles/mastodon/_variables.scss @@ -13,6 +13,3 @@ $no-gap-breakpoint: 1175px; $mobile-menu-breakpoint: 760px; $mobile-breakpoint: 630px; $no-columns-breakpoint: 600px; - -$font-sans-serif: 'mastodon-font-sans-serif' !default; -$font-monospace: 'mastodon-font-monospace' !default; diff --git a/app/javascript/styles/mastodon/basics.scss b/app/javascript/styles/mastodon/basics.scss index a16afbe9a57..87bbe20c733 100644 --- a/app/javascript/styles/mastodon/basics.scss +++ b/app/javascript/styles/mastodon/basics.scss @@ -8,6 +8,14 @@ html { scrollbar-color: var(--color-text-secondary) var(--color-bg-secondary); } + --font-body: mastodon-font-sans-serif, sans-serif; + --font-heading: Syne, sans-serif; + --font-monospace: mastodon-font-monospace, monospace; + + &[data-redesign='true'] { + --font-body: Inter, sans-serif; + } + --outline-focus-default: 2px solid var(--color-border-brand); --avatar-border-radius: 8px; --max-media-height-small: 460px; @@ -45,7 +53,7 @@ html.has-modal { } body { - font-family: $font-sans-serif, sans-serif; + font-family: var(--font-body); background: var(--color-bg-primary); font-size: 13px; line-height: 18px; @@ -73,7 +81,6 @@ body { // Fira Sans => Firefox OS // Droid Sans => Older Androids (<4.0) // Helvetica Neue => Older macOS <10.11 - // $font-sans-serif => web-font (Roboto) fallback and newer Androids (>=4.0) font-family: system-ui, -apple-system, @@ -85,7 +92,6 @@ body { 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - $font-sans-serif, sans-serif; } diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index b7c4efc172b..11f5d60702b 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -984,7 +984,7 @@ body > [data-popover-placement] { .character-counter { cursor: default; - font-family: $font-sans-serif, sans-serif; + font-family: var(--font-body); font-size: 14px; font-weight: 400; line-height: normal; diff --git a/app/javascript/styles/mastodon/forms.scss b/app/javascript/styles/mastodon/forms.scss index 5791b4fc001..3c68f6e0614 100644 --- a/app/javascript/styles/mastodon/forms.scss +++ b/app/javascript/styles/mastodon/forms.scss @@ -2,7 +2,7 @@ @use 'variables' as *; code { - font-family: $font-monospace, monospace; + font-family: var(--font-monospace); font-weight: 400; } @@ -895,7 +895,7 @@ code { width: 100%; border: 0; padding: 10px; - font-family: $font-monospace, monospace; + font-family: var(--font-monospace); background: var(--color-bg-secondary); color: var(--color-text-primary); font-size: 14px; @@ -1146,7 +1146,7 @@ code { .form_admin_settings_custom_css, .form_admin_settings_closed_registrations_message { textarea { - font-family: $font-monospace, monospace; + font-family: var(--font-monospace); } } @@ -1171,7 +1171,7 @@ code { border: 0; padding: 10px; font-size: 14px; - font-family: $font-monospace, monospace; + font-family: var(--font-monospace); } button { diff --git a/app/javascript/styles/mastodon/tables.scss b/app/javascript/styles/mastodon/tables.scss index 2e2d1bd41fe..338a8aa30d1 100644 --- a/app/javascript/styles/mastodon/tables.scss +++ b/app/javascript/styles/mastodon/tables.scss @@ -168,7 +168,7 @@ } samp { - font-family: $font-monospace, monospace; + font-family: var(--font-monospace); } button.table-action-link { diff --git a/spec/requests/content_security_policy_spec.rb b/spec/requests/content_security_policy_spec.rb index c84c3802f24..64df49b14e6 100644 --- a/spec/requests/content_security_policy_spec.rb +++ b/spec/requests/content_security_policy_spec.rb @@ -32,7 +32,7 @@ RSpec.describe 'Content-Security-Policy' do img-src 'self' data: blob: #{local_domain} manifest-src 'self' #{local_domain} media-src 'self' data: #{local_domain} - script-src 'self' #{local_domain} 'wasm-unsafe-eval' 'sha256-Z5KW83D+6/pygIQS3h9XDpF52xW3l3BHc7JL9tj3uMs=' + script-src 'self' #{local_domain} 'wasm-unsafe-eval' 'sha256-OgOg5CGI7D4Syg38sNIknJKO+3DCTdpfY1ciC+Bklaw=' style-src 'self' #{local_domain} 'nonce-ZbA+JmE7+bK8F5qvADZHuQ==' worker-src 'self' blob: #{local_domain} CSP