Skip to content

Commit

Permalink
Font improvements, loading fonts in Storybook, and adding more font C…
Browse files Browse the repository at this point in the history
…hromatic stories (#4238)
  • Loading branch information
ktabors authored Apr 5, 2023
1 parent 1d6ed94 commit f239d0b
Show file tree
Hide file tree
Showing 11 changed files with 489 additions and 91 deletions.
208 changes: 149 additions & 59 deletions .chromatic/preview-head.html

Large diffs are not rendered by default.

25 changes: 24 additions & 1 deletion .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
<link rel="stylesheet" href="https://use.typekit.net/uma8ayv.css" />
<!--
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
-->

<!-- This file loads adobe clean, adobe clean serif, myriad-arabic, myriad-hebrew, adobe-clean-han-japanese, adobe-clean-han-korean, adobe-clean-han-simplified-c, and adobe-clean-han-traditional.
Access to these fonts was provided to a team account. -->
<script>
(function(d) {
var config = {
kitId: 'uei1lip',
scriptTimeout: 3000,
async: true
},
h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)
})(document);
</script>
36 changes: 25 additions & 11 deletions packages/@adobe/spectrum-css-temp/components/commons/fonts.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ governing permissions and limitations under the License.
*/

:root {
--spectrum-font-fallbacks-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
--spectrum-font-fallbacks-sans: adobe-clean, 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Trebuchet MS', 'Lucida Grande', sans-serif;

font-synthesis: weight;

/* Not used
--spectrum-font-fallbacks-serif: serif;
Expand All @@ -27,15 +29,15 @@ governing permissions and limitations under the License.
--spectrum-font-family-condensed: adobe-clean-condensed, var(--spectrum-font-family-base);
*/

--spectrum-font-family-base: 'adobe-clean-ux', 'adobe-clean', 'Source Sans Pro', var(--spectrum-font-fallbacks-sans);
--spectrum-font-family-base: var(--spectrum-font-fallbacks-sans);
--spectrum-font-family-han: 'adobe-clean-han-japanese', var(--spectrum-font-fallbacks-sans);
--spectrum-font-family-ar: 'adobe-arabic', 'myriad-arabic', var(--spectrum-font-fallbacks-sans);
--spectrum-font-family-he: 'adobe-hebrew', var(--spectrum-font-fallbacks-sans);
--spectrum-font-family-zhhans: 'adobe-clean-han-simplified-c', 'SimSun', 'Heiti SC Light', var(--spectrum-font-fallbacks-sans);
--spectrum-font-family-zh: var(--spectrum-font-family-zhhans);
--spectrum-font-family-zhhant: 'adobe-clean-han-traditional', 'Microsoft JhengHei UI', 'Microsoft JhengHei', 'Heiti TC Light', var(--spectrum-font-fallbacks-sans);
--spectrum-font-family-ko: 'adobe-clean-han-korean', 'Malgun Gothic', 'Apple Gothic', var(--spectrum-font-fallbacks-sans);
--spectrum-font-family-ja: 'adobe-clean-han-japanese', 'Yu Gothic', '\30E1 \30A4 \30EA \30AA', '\30D2 \30E9 \30AE \30CE \89D2 \30B4 Pro W3', 'Hiragino Kaku Gothic Pro W3', 'Osaka', '\FF2D \FF33 \FF30 \30B4 \30B7 \30C3 \30AF', 'MS PGothic', var(--spectrum-font-fallbacks-sans);
--spectrum-font-family-ar: 'myriad-arabic', var(--spectrum-font-fallbacks-sans);
--spectrum-font-family-he: 'myriad-hebrew', var(--spectrum-font-fallbacks-sans);
--spectrum-font-family-zhhans: adobe-clean-han-simplified-c, source-han-simplified-c, 'SimSun', 'Heiti SC Light', sans-serif;
--spectrum-font-family-zh: adobe-clean-han-traditional, source-han-traditional, 'MingLiu', 'Heiti TC Light', sans-serif;
--spectrum-font-family-zhhant: adobe-clean-han-traditional, source-han-traditional, 'MingLiu', 'Microsoft JhengHei UI', 'Microsoft JhengHei', 'Heiti TC Light', sans-serif;
--spectrum-font-family-ko: adobe-clean-han-korean, source-han-korean, 'Malgun Gothic', 'Apple Gothic', sans-serif;
--spectrum-font-family-ja: adobe-clean-han-japanese, 'Hiragino Kaku Gothic ProN', 'ヒラギノ角ゴ ProN W3', Osaka, YuGothic, 'Yu Gothic', 'メイリオ', Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif;
--spectrum-text-size: var(--spectrum-alias-font-size-default);
--spectrum-text-body-line-height: var(--spectrum-alias-line-height-medium);
--spectrum-text-size-text-label: var(--spectrum-label-text-size);
Expand All @@ -53,12 +55,24 @@ governing permissions and limitations under the License.
font-family: var(--spectrum-font-family-he);
}

&:lang(zh) {
font-family: var(--spectrum-font-family-zh);
}

&:lang(zh-Hans) {
font-family: var(--spectrum-font-family-zhhans);
}

&:lang(zh) {
font-family: var(--spectrum-font-family-zh);
&:lang(zh-Hant) {
font-family: var(--spectrum-font-family-zhhant);
}

&:lang(zh-SG) {
font-family: var(--spectrum-font-family-zhhans);
}

&:lang(zh-CN) {
font-family: var(--spectrum-font-family-zhhans);
}

&:lang(ko) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,16 @@ storiesOf('Button/ActionButton', module)
</Flex>
</View>
)
)
);

storiesOf('Languages/ActionButton', module)
.addParameters({
chromaticProvider: {
colorSchemes: ['light'],
express: false,
locales: ['en-US', 'ja-JP'],
scales: ['large', 'medium']
}})
.add(
'Japanese, icon + text, staticColor: white',
() => (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
import {ComponentMeta, ComponentStoryObj} from '@storybook/react';
import {Content} from '@react-spectrum/view';
import {Flex} from '@react-spectrum/layout';
import {Heading} from '@react-spectrum/text';
import {IllustratedMessage} from '..';
import NotFound from '@spectrum-icons/illustrations/src/NotFound';
import React from 'react';

type IllustratedMessageStory = ComponentStoryObj<typeof IllustratedMessage>;

export default {
title: 'Languages/IllustratedMessage',
component: IllustratedMessage,
parameters: {
chromaticProvider: {
colorSchemes: ['light'],
express: false,
locales: ['ar-AE', 'zh-CN', 'zh-TW', 'ja-JP', 'ko-KR'],
scales: ['large', 'medium']
}
}
} as ComponentMeta<typeof IllustratedMessage>;

export const _NotFound: IllustratedMessageStory = {
render: () => (
<Flex gap="size-200" direction="row" wrap>
<IllustratedMessage width="size-2000">
<NotFound />
<Heading>Error 404</Heading>
<Content>Page not found</Content>
</IllustratedMessage>
<IllustratedMessage width="size-2000">
<NotFound />
<Heading>404 خطأ</Heading>
<Content>الصفحة غير موجودة</Content>
</IllustratedMessage>
<IllustratedMessage width="size-2000">
<NotFound />
<Heading>错误 404</Heading>
<Content>找不到网页</Content>
</IllustratedMessage>
<IllustratedMessage width="size-2000">
<NotFound />
<Heading>錯誤 404</Heading>
<Content>找不到網頁</Content>
</IllustratedMessage>
<IllustratedMessage width="size-2000">
<NotFound />
<Heading>エラー 404</Heading>
<Content>ページが見つかりません</Content>
</IllustratedMessage>
<IllustratedMessage width="size-2000">
<NotFound />
<Heading>오류 404</Heading>
<Content>페이지를 찾을 수 없음</Content>
</IllustratedMessage>
</Flex>
),
name: 'Not found: no italic in CCJK'
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2023 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
import {ComponentMeta, Story} from '@storybook/react';
import {Item, Picker, Section} from '..';
import React from 'react';
import {SpectrumPickerProps} from '@react-types/select';

export default {
title: 'Languages/Picker',
component: Picker,
parameters: {
chromaticProvider: {colorSchemes: ['light'], express: false, locales: ['en-US'], scales: ['large', 'medium']}
}
} as ComponentMeta<typeof Picker>;

const Template = <T extends object>(): Story<SpectrumPickerProps<T>> => (args) => (
<Picker {...args}>
<Section title="Animals">
<Item key="Aardvark">Aardvark</Item>
<Item key="Kangaroo">Kangaroo</Item>
<Item key="Snake">Snake</Item>
</Section>
<Section title="People">
<Item key="Danni">Danni</Item>
<Item key="Devon">Devon</Item>
<Item key="Ross">Ross</Item>
</Section>
</Picker>
);

export const ArabicPlaceholder = Template().bind({});
ArabicPlaceholder.args = {label: 'Pick your favorite', placeholder: 'دولفين'};
ArabicPlaceholder.parameters = {
chromaticProvider: {locales: ['ar-AE']}
};

export const ChineseSimplifiedPlaceholder = Template().bind({});
ChineseSimplifiedPlaceholder.args = {label: 'Pick your favorite', placeholder: '海豚'};
ChineseSimplifiedPlaceholder.parameters = {
chromaticProvider: {locales: ['zh-CN']}
};

export const ChineseTraditionalPlaceholder = Template().bind({});
ChineseTraditionalPlaceholder.args = {label: 'Pick your favorite', placeholder: '海豚'};
ChineseTraditionalPlaceholder.parameters = {
chromaticProvider: {locales: ['zh-TW']}
};

export const JapanesePlaceholder = Template().bind({});
JapanesePlaceholder.args = {label: 'Pick your favorite', placeholder: 'イルカ'};
JapanesePlaceholder.parameters = {
chromaticProvider: {locales: ['ja-JP']}
};

export const KoreanPlaceholder = Template().bind({});
KoreanPlaceholder.args = {label: 'Pick your favorite', placeholder: '돌고래'};
KoreanPlaceholder.parameters = {
chromaticProvider: {locales: ['ko-KR']}
};
13 changes: 12 additions & 1 deletion packages/@react-spectrum/provider/stories/Provider.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,18 @@ storiesOf('Provider', module)
<Breakpoint />
</Provider>
);
});
})
.add(
'locale: zh-Hant',
() => (
<div>
<div>Heaven and earth are mysterious and yellow, the universe is prehistoric</div>
<Provider locale="zh-Hant">
<div>天地玄黃,宇宙洪荒</div>
</Provider>
</div>
)
);

function render(props = {}) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,29 @@ storiesOf('StatusLight', module)
)
);

storiesOf('Languages/StatusLight', module)
.addParameters({
chromaticProvider: {
colorSchemes: ['light'],
express: false,
locales: ['ar-AE', 'zh-CN', 'zh-TW', 'ja-JP', 'ko-KR'],
scales: ['large', 'medium']
}
})
.add(
'Neutral: no italic in CCJK',
() => (
<Flex gap="size-200" direction="row" wrap>
<StatusLight variant="neutral">Help</StatusLight>
<StatusLight variant="neutral">مساعدة</StatusLight>
<StatusLight variant="neutral">帮助</StatusLight>
<StatusLight variant="neutral">說明</StatusLight>
<StatusLight variant="neutral">ヘルプ</StatusLight>
<StatusLight variant="neutral">도움말</StatusLight>
</Flex>
)
);

function render() {
return (
<Flex wrap>
Expand Down
28 changes: 19 additions & 9 deletions packages/@react-spectrum/textfield/chromatic/TextArea.chromatic.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {storiesOf} from '@storybook/react';
import {TextArea} from '../';

storiesOf('TextArea', module)
.addParameters({chromaticProvider: {locales: ['en-US', 'ar-AE', 'zh-TW']}})
.addParameters({chromaticProvider: {locales: ['en-US', 'ar-AE']}})
.add(
'Default',
() => render()
Expand Down Expand Up @@ -85,14 +85,6 @@ storiesOf('TextArea', module)
.add('custom height',
() => render({icon: <Info />, validationState: 'invalid', height: 350})
)
.add(
'value: 測試, icon: Info, labelPosition: side, validationState: valid',
() => render({value: '測試', icon: <Info />, labelPosition: 'side', validationState: 'valid'})
)
.add(
'value: اختبار, isRequired: false, necessityIndicator: label',
() => render({value: 'اختبار', isRequired: false, necessityIndicator: 'label'})
)
.add(
'contextual help',
args => render({...args, contextualHelp: (
Expand Down Expand Up @@ -121,6 +113,24 @@ storiesOf('TextArea', module)
)}, false)
);

storiesOf('Languages/TextArea', module)
.addParameters({
chromaticProvider: {
colorSchemes: ['light'],
express: false,
locales: ['ar-AE', 'zh-TW'],
scales: ['large', 'medium']
}
})
.add(
'value: 測試, icon: Info, labelPosition: side, validationState: valid',
() => render({value: '測試', icon: <Info />, labelPosition: 'side', validationState: 'valid'})
)
.add(
'value: اختبار, isRequired: false, necessityIndicator: label',
() => render({value: 'اختبار', isRequired: false, necessityIndicator: 'label'})
);

// allow some stories where disabled styles probably won't affect anything to turn that off, mostly to reduce clutter
function render(props = {}, disabled = true) {
return (
Expand Down
Loading

1 comment on commit f239d0b

@rspbot
Copy link

@rspbot rspbot commented on f239d0b Apr 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.