Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Support styled @font-face generation #152

Merged
merged 14 commits into from
May 1, 2019
Merged

Support styled @font-face generation #152

merged 14 commits into from
May 1, 2019

Conversation

angus-c
Copy link
Contributor

@angus-c angus-c commented Apr 30, 2019

No description provided.

@codecov
Copy link

codecov bot commented Apr 30, 2019

Codecov Report

Merging #152 into master will increase coverage by 5.21%.
The diff coverage is 90.32%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #152      +/-   ##
==========================================
+ Coverage   47.72%   52.94%   +5.21%     
==========================================
  Files           9        9              
  Lines         132      153      +21     
  Branches       23       32       +9     
==========================================
+ Hits           63       81      +18     
- Misses         69       72       +3
Impacted Files Coverage Δ
src/generate-preload-links.js 100% <ø> (ø) ⬆️
src/preload-session.js 33.33% <ø> (ø) ⬆️
src/with-font-loading.js 4.34% <0%> (-0.42%) ⬇️
src/generate-fallback-map.js 100% <100%> (ø) ⬆️
src/plugin.js 95.65% <100%> (+2.31%) ⬆️
src/generate-font-faces.js 95.23% <93.33%> (-4.77%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 54f72cd...96c9d5b. Read the comment docs.

@codecov
Copy link

codecov bot commented Apr 30, 2019

Codecov Report

Merging #152 into master will increase coverage by 5.21%.
The diff coverage is 90.32%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #152      +/-   ##
==========================================
+ Coverage   47.72%   52.94%   +5.21%     
==========================================
  Files           9        9              
  Lines         132      153      +21     
  Branches       23       32       +9     
==========================================
+ Hits           63       81      +18     
- Misses         69       72       +3
Impacted Files Coverage Δ
src/generate-preload-links.js 100% <ø> (ø) ⬆️
src/preload-session.js 33.33% <ø> (ø) ⬆️
src/with-font-loading.js 4.34% <0%> (-0.42%) ⬇️
src/generate-fallback-map.js 100% <100%> (ø) ⬆️
src/plugin.js 95.65% <100%> (+2.31%) ⬆️
src/generate-font-faces.js 95.23% <93.33%> (-4.77%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 54f72cd...b0862db. Read the comment docs.

2 similar comments
@codecov
Copy link

codecov bot commented Apr 30, 2019

Codecov Report

Merging #152 into master will increase coverage by 5.21%.
The diff coverage is 90.32%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #152      +/-   ##
==========================================
+ Coverage   47.72%   52.94%   +5.21%     
==========================================
  Files           9        9              
  Lines         132      153      +21     
  Branches       23       32       +9     
==========================================
+ Hits           63       81      +18     
- Misses         69       72       +3
Impacted Files Coverage Δ
src/generate-preload-links.js 100% <ø> (ø) ⬆️
src/preload-session.js 33.33% <ø> (ø) ⬆️
src/with-font-loading.js 4.34% <0%> (-0.42%) ⬇️
src/generate-fallback-map.js 100% <100%> (ø) ⬆️
src/plugin.js 95.65% <100%> (+2.31%) ⬆️
src/generate-font-faces.js 95.23% <93.33%> (-4.77%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 54f72cd...b0862db. Read the comment docs.

@codecov
Copy link

codecov bot commented Apr 30, 2019

Codecov Report

Merging #152 into master will increase coverage by 5.21%.
The diff coverage is 90.32%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #152      +/-   ##
==========================================
+ Coverage   47.72%   52.94%   +5.21%     
==========================================
  Files           9        9              
  Lines         132      153      +21     
  Branches       23       32       +9     
==========================================
+ Hits           63       81      +18     
- Misses         69       72       +3
Impacted Files Coverage Δ
src/generate-preload-links.js 100% <ø> (ø) ⬆️
src/preload-session.js 33.33% <ø> (ø) ⬆️
src/with-font-loading.js 4.34% <0%> (-0.42%) ⬇️
src/generate-fallback-map.js 100% <100%> (ø) ⬆️
src/plugin.js 95.65% <100%> (+2.31%) ⬆️
src/generate-font-faces.js 95.23% <93.33%> (-4.77%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 54f72cd...b0862db. Read the comment docs.

@angus-c angus-c requested a review from nadiia April 30, 2019 23:50
export function getFontConfig(
withStyleOverloads: boolean,
preloadOverrides?: {}
) {
Copy link
Member

@AlexMSmithCA AlexMSmithCA May 1, 2019

Choose a reason for hiding this comment

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

Is there a concrete type for this config object that folks can use? Ideally they could write their own and Flow would complain at the source if they did something like:

import type {FontConfigType} from '...';

const config: FontConfigType = {
   ...
};

Right now, the fonts property looks like it'll be a union of AtomicFontsObjectType and StyledFontsObjectType which may be more clear for consumers if given an overall type for the entire config.

function asFontFaceSrc(urls) {
// `urls` is a dictionary of font types (woff, woff2 etc) to url string
return Object.keys(urls).map(
type => `url("${urls[type]}") format("${type}")\n`
// $FlowFixMe
Copy link
Member

Choose a reason for hiding this comment

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

Hm, curious as to why this is necessary?

Copy link
Contributor Author

@angus-c angus-c May 1, 2019

Choose a reason for hiding this comment

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

I'm not entirely sure but it relates to

type FontURLsType = {
  woff?: string,
  woff2: string,
};

Because woff is an optional key it is somehow inferring that urls(type) might be undefined.

Copy link
Member

@AlexMSmithCA AlexMSmithCA May 1, 2019

Choose a reason for hiding this comment

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

Ah, that's annoying. I think this is because an object with the propery woff: undefined satisfies the type constraints and would fail the urls[type] coercion because it may be undefined. Something like this:

const urls: FontURLsType = {
  woff: undefined,
  woff2: "hello"
};

console.log(Object.keys(urls)); // ['woff', 'woff2'];

If you want to get rid of this $FlowFixMe you could wrap the offending code in a String constructor:

type => `url("${String(urls[type])}") format("${type}")`

which should resolve this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

};

export type ConfigType = {
Copy link
Member

Choose a reason for hiding this comment

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

Ah, nevermind. Here it is! Disregard earlier comment, assuming we export this in index.js as well.

AlexMSmithCA
AlexMSmithCA previously approved these changes May 1, 2019
AlexMSmithCA
AlexMSmithCA previously approved these changes May 1, 2019
@fusionjs-bot
Copy link

fusionjs-bot bot commented May 1, 2019

Triggered Fusion.js build verification: https://buildkite.com/uberopensource/fusion-release-verification/builds/2030

@fusionjs-bot fusionjs-bot bot deleted the style-overloads branch May 1, 2019 16:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants