-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #300 from twreporter/master
chore: release
- Loading branch information
Showing
22 changed files
with
553 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,18 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
# [1.5.0-rc.0](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/[email protected]...@twreporter/[email protected]) (2022-08-10) | ||
|
||
|
||
### Features | ||
|
||
* **core:** add `defaultFallback` font-family into font ([c7a84a2](https://github.com/twreporter/twreporter-npm-packages/commit/c7a84a23f1bf001717dbf0c7be7711f132dc9b93)) | ||
* **core:** export fonts as a constant ([c9c9cdc](https://github.com/twreporter/twreporter-npm-packages/commit/c9c9cdcb3a0c7b3368d56d09ea73780533ff9ab7)) | ||
|
||
|
||
|
||
|
||
|
||
## [1.4.2](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/[email protected]...@twreporter/[email protected]) (2022-08-09) | ||
|
||
**Note:** Version bump only for package @twreporter/core | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@twreporter/core", | ||
"version": "1.4.2", | ||
"version": "1.5.0-rc.0", | ||
"main": "lib/index.js", | ||
"repository": "https://github.com/twreporter/twreporter-npm-packages.git", | ||
"author": "twreporter <[email protected]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,32 @@ | ||
const merriweather = 'merriweather' | ||
const notoSerifTC = 'Noto Serif TC' | ||
const serif = 'serif' | ||
const rosario = 'rosario' | ||
const notoSansTC = 'Noto Sans TC' | ||
const sansSerif = 'sans-serif' | ||
|
||
const fonts = { | ||
merriweather, | ||
notoSerifTC, | ||
serif, | ||
rosario, | ||
notoSansTC, | ||
sansSerif, | ||
} | ||
|
||
const fontWeight = { | ||
extraLight: '100', | ||
normal: '400', | ||
bold: '700', | ||
} | ||
|
||
const fontFamily = { | ||
title: 'merriweather, Noto Serif TC, serif', | ||
default: 'rosario, Noto Sans TC, sans-serif', | ||
title: `${merriweather}, ${notoSerifTC}, ${serif}`, | ||
default: `${rosario}, ${notoSansTC}, ${sansSerif}`, | ||
// use defaultFallback before ${notoSansTC} is fully loaded | ||
defaultFallback: `${rosario}, ${sansSerif}`, | ||
} | ||
|
||
export default { fontWeight, fontFamily } | ||
export default { fonts, fontWeight, fontFamily } | ||
|
||
export { fontWeight, fontFamily } | ||
export { fonts, fontWeight, fontFamily } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,22 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [1.3.2-rc.1](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/[email protected]...@twreporter/[email protected]) (2022-08-10) | ||
|
||
**Note:** Version bump only for package @twreporter/index-page | ||
|
||
|
||
|
||
|
||
|
||
## [1.3.2-rc.0](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/[email protected]...@twreporter/[email protected]) (2022-08-10) | ||
|
||
**Note:** Version bump only for package @twreporter/index-page | ||
|
||
|
||
|
||
|
||
|
||
## [1.3.1](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/[email protected]...@twreporter/[email protected]) (2022-08-09) | ||
|
||
**Note:** Version bump only for package @twreporter/index-page | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@twreporter/index-page", | ||
"version": "1.3.1", | ||
"version": "1.3.2-rc.1", | ||
"main": "lib/index.js", | ||
"repository": "https://github.com/twreporter/twreporter-npm-packages.git", | ||
"author": "twreporter <[email protected]>", | ||
|
@@ -12,8 +12,8 @@ | |
"prepublishOnly": "make build" | ||
}, | ||
"dependencies": { | ||
"@twreporter/core": "^1.4.2", | ||
"@twreporter/react-components": "^8.11.1", | ||
"@twreporter/core": "^1.5.0-rc.0", | ||
"@twreporter/react-components": "^8.12.0-rc.1", | ||
"lodash": "^4.0.0", | ||
"prop-types": "^15.0.0", | ||
"react": "^16.3.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,22 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [1.6.3-rc.1](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/[email protected]...@twreporter/[email protected]) (2022-08-10) | ||
|
||
**Note:** Version bump only for package @twreporter/react-article-components | ||
|
||
|
||
|
||
|
||
|
||
## [1.6.3-rc.0](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/[email protected]...@twreporter/[email protected]) (2022-08-10) | ||
|
||
**Note:** Version bump only for package @twreporter/react-article-components | ||
|
||
|
||
|
||
|
||
|
||
## [1.6.2](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/[email protected]...@twreporter/[email protected]) (2022-08-09) | ||
|
||
**Note:** Version bump only for package @twreporter/react-article-components | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,42 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
# [8.12.0-rc.1](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/[email protected]...@twreporter/[email protected]) (2022-08-10) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* add releaseBranch props for icon component ([bad00f5](https://github.com/twreporter/twreporter-npm-packages/commit/bad00f59878b08d15d52a58ac876f1fb210d101b)) | ||
* address code review ([13aad8e](https://github.com/twreporter/twreporter-npm-packages/commit/13aad8ec84d702af53be830d1ecdb482c15efd3a)) | ||
* remove DesktopTab in TitleTab component ([cde0983](https://github.com/twreporter/twreporter-npm-packages/commit/cde098305d6bdf9ebe847aebf9d70f253520608c)) | ||
|
||
|
||
### Features | ||
|
||
* add title bar component for design guideline ([b96bdde](https://github.com/twreporter/twreporter-npm-packages/commit/b96bdde414bf068eb9521a627ce0414eb95867e2)) | ||
|
||
|
||
|
||
|
||
|
||
# [8.12.0-rc.0](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/[email protected]...@twreporter/[email protected]) (2022-08-10) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* **react-components:** add callback as dep of use-font-observer-hook ([9f91ce9](https://github.com/twreporter/twreporter-npm-packages/commit/9f91ce928b0e94c8b29600f44438ea37f45e5c03)) | ||
|
||
|
||
### Features | ||
|
||
* **react-components:** add NotoSansTC fontface ([046cdb5](https://github.com/twreporter/twreporter-npm-packages/commit/046cdb501b5133fb120cf66401929145ad2c79da)) | ||
* **react-components:** add use-font-face-observer hook ([f2ffa6d](https://github.com/twreporter/twreporter-npm-packages/commit/f2ffa6d9215737046d246aa34dd468a2ff0d15f2)) | ||
* **react-components:** export font files as `fontGCSFiles` ([a8b940c](https://github.com/twreporter/twreporter-npm-packages/commit/a8b940c796dc039cb769f09b8d6bcc0002a22bcf)) | ||
|
||
|
||
|
||
|
||
|
||
## [8.11.1](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/[email protected]...@twreporter/[email protected]) (2022-08-09) | ||
|
||
**Note:** Version bump only for package @twreporter/react-components | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@twreporter/react-components", | ||
"version": "8.11.1", | ||
"version": "8.12.0-rc.1", | ||
"main": "lib/index.js", | ||
"repository": "https://github.com/twreporter/twreporter-npm-packages.git", | ||
"author": "twreporter <[email protected]>", | ||
|
@@ -15,8 +15,9 @@ | |
"chromatic": "npx chromatic --exit-zero-on-changes" | ||
}, | ||
"dependencies": { | ||
"@twreporter/core": "^1.4.2", | ||
"@twreporter/core": "^1.5.0-rc.0", | ||
"@twreporter/redux": "^7.2.2", | ||
"fontfaceobserver-es": "^3.3.3", | ||
"hoist-non-react-statics": "^2.3.1", | ||
"lodash": "^4.0.0", | ||
"memoize-one": "^5.0.5", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { Link } from 'react-router-dom' | ||
|
||
const CustomizedLink = ({ isExternal, to, ...rest }) => { | ||
if (isExternal) { | ||
return <a href={to} {...rest} /> | ||
} | ||
return <Link to={to} {...rest} /> | ||
} | ||
|
||
CustomizedLink.propTypes = { | ||
isExternal: PropTypes.bool, | ||
to: PropTypes.string, | ||
} | ||
|
||
CustomizedLink.defaultProps = { | ||
isExternal: true, | ||
to: '', | ||
} | ||
|
||
export default CustomizedLink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import useOutsideClick from './use-outside-click' | ||
import useFontFaceObserver from './use-font-face-observer' | ||
|
||
export { useOutsideClick } | ||
export { useOutsideClick, useFontFaceObserver } | ||
|
||
export default { | ||
useOutsideClick, | ||
useFontFaceObserver, | ||
} |
36 changes: 36 additions & 0 deletions
36
packages/react-components/src/hook/use-font-face-observer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useState, useEffect } from 'react' | ||
import FontFaceObserver from 'fontfaceobserver-es' | ||
|
||
const useFontFaceObserver = (fontFaces = [], callback) => { | ||
const [isResolved, setIsResolved] = useState(false) | ||
const fontFacesString = JSON.stringify(fontFaces) | ||
|
||
useEffect(() => { | ||
const promises = JSON.parse(fontFacesString).map( | ||
({ family, weight, style, stretch }) => | ||
new FontFaceObserver(family, { | ||
weight, | ||
style, | ||
stretch, | ||
}).load('測試文字') | ||
) | ||
|
||
Promise.all(promises) | ||
.then(() => { | ||
if (typeof callback !== 'function') { | ||
return | ||
} | ||
callback() | ||
return setIsResolved(true) | ||
}) | ||
.catch(e => { | ||
// eslint-disable-next-line no-console | ||
console.error(`An error occurred during font loading`) | ||
console.log(e) | ||
}) | ||
}, [fontFacesString, callback]) | ||
|
||
return isResolved | ||
} | ||
|
||
export default useFontFaceObserver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { fonts, fontWeight } from '@twreporter/core/lib/constants/font' | ||
// lodash | ||
import forEach from 'lodash/forEach' | ||
import keys from 'lodash/keys' | ||
import reduce from 'lodash/reduce' | ||
|
||
const _ = { | ||
forEach, | ||
keys, | ||
reduce, | ||
} | ||
|
||
const baseGCSDir = 'https://www.twreporter.org/assets/font/' | ||
const fileExt = '.woff2' | ||
|
||
const gcsFontFolder = { | ||
[fonts.notoSansTC]: 'NotoSansTC', | ||
} | ||
|
||
const fontWeightKeys = _.keys(fontWeight) | ||
|
||
// add @font-face to global style to use self-hosted font for performance reasons, to be more precise please check the issue below: | ||
// https://twreporter-org.atlassian.net/browse/TWREPORTER-318?atlOrigin=eyJpIjoiNjg4OTQ2MWU2MGIxNGEzMGE0NDY2ZDNmZGRhOWExZDEiLCJwIjoiaiJ9 | ||
const getFontFaces = ({ font, folder }) => { | ||
const fontFaceCSSTemplate = ({ fontWeightKey }) => ` | ||
@font-face { | ||
font-family: "${font}"; | ||
font-weight: ${fontWeight[fontWeightKey]}; | ||
font-display: swap; | ||
src: url("${baseGCSDir}${folder}/${fontWeightKey}${fileExt}"); | ||
} | ||
` | ||
return _.reduce( | ||
fontWeightKeys, | ||
(fontFaces, fontWeightKey) => { | ||
return fontFaces + fontFaceCSSTemplate({ fontWeightKey }) | ||
}, | ||
'' | ||
) | ||
} | ||
|
||
const fontFaces = { | ||
[fonts.notoSansTC]: getFontFaces({ | ||
font: fonts.notoSansTC, | ||
folder: gcsFontFolder[fonts.notoSansTC], | ||
}), | ||
} | ||
|
||
let fontGCSFiles = [] | ||
|
||
_.forEach(fontFaces, function(fontFace, font) { | ||
_.forEach(fontWeightKeys, fontWeightKey => { | ||
fontGCSFiles.push( | ||
`${baseGCSDir}${gcsFontFolder[font]}/${fontWeightKey}${fileExt}` | ||
) | ||
}) | ||
}) | ||
|
||
export default { fontFaces, fontGCSFiles } |
Oops, something went wrong.
11f95aa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
react-components – ./
react-components-git-master-twreporter.vercel.app
twreporter-components-storybook.vercel.app
react-components-twreporter.vercel.app