Skip to content

Commit

Permalink
Adjustments after #1323 merge. Revert content as parameter to load fo…
Browse files Browse the repository at this point in the history
…nt (To address #923).
  • Loading branch information
obetomuniz committed May 7, 2020
1 parent 94fec7d commit b7a18ba
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
5 changes: 3 additions & 2 deletions assets/src/edit-story/app/font/actions/useLoadFontFiles.js
Expand Up @@ -55,6 +55,7 @@ function useLoadFontFiles() {
font: { family, service, variants },
fontWeight,
isItalic,
content,
}) => {
if (!family || service !== 'fonts.google.com') {
return null;
Expand Down Expand Up @@ -89,8 +90,8 @@ function useLoadFontFiles() {

const ensureFontLoaded = async () => {
if (document?.fonts) {
await document.fonts.load(fontFaceSet);
return document.fonts.check(fontFaceSet);
await document.fonts.load(fontFaceSet, content || '');
return document.fonts.check(fontFaceSet, content || '');
} else {
return null;
}
Expand Down
Expand Up @@ -30,7 +30,8 @@ const DEFAULT_FONT = {
service: 'fonts.google.com',
},
fontWeight: 400,
fontStyle: 'normal',
isItalic: true,
content: 'Fill in some text',
};

describe('useLoadFontFiles', () => {
Expand Down
15 changes: 4 additions & 11 deletions assets/src/edit-story/components/library/text/fontPreview.js
Expand Up @@ -53,14 +53,7 @@ const Text = styled.span`
color: ${({ theme }) => theme.colors.fg.v1};
`;

function FontPreview({
title,
font,
fontSize,
fontWeight,
fontStyle,
onClick,
}) {
function FontPreview({ title, font, fontSize, fontWeight, content, onClick }) {
const {
actions: { maybeEnqueueFontStyle },
} = useFont();
Expand All @@ -70,10 +63,10 @@ function FontPreview({
{
font,
fontWeight,
fontStyle,
content,
},
]);
}, [font, fontWeight, fontStyle, maybeEnqueueFontStyle]);
}, [font, fontWeight, content, maybeEnqueueFontStyle]);

return (
<Preview onClick={onClick}>
Expand All @@ -93,7 +86,7 @@ FontPreview.propTypes = {
font: FontPropType,
fontSize: PropTypes.number,
fontWeight: PropTypes.number,
fontStyle: PropTypes.string,
content: PropTypes.string,
onClick: PropTypes.func,
};

Expand Down
6 changes: 4 additions & 2 deletions assets/src/edit-story/components/panels/textStyle/font.js
Expand Up @@ -90,10 +90,11 @@ function FontControls({ selectedElements, pushUpdate }) {
};

await maybeEnqueueFontStyle(
selectedElements.map(() => ({
selectedElements.map(({ content }) => ({
font: newFont,
isItalic,
fontWeight,
content,
}))
);

Expand All @@ -118,10 +119,11 @@ function FontControls({ selectedElements, pushUpdate }) {
value={fontWeight}
onChange={async (value) => {
await maybeEnqueueFontStyle(
selectedElements.map(({ font }) => ({
selectedElements.map(({ font, content }) => ({
font,
isItalic,
fontWeight: parseInt(value),
content,
}))
);
handleSelectFontWeight(value);
Expand Down
Expand Up @@ -143,10 +143,11 @@ function StylePanel({ selectedElements, pushUpdate }) {
iconHeight={10}
onChange={async (value) => {
await maybeEnqueueFontStyle(
selectedElements.map(({ font }) => ({
selectedElements.map(({ font, content }) => ({
font,
isItalic: value,
fontWeight,
content,
}))
);
handleClickItalic(value);
Expand Down
3 changes: 2 additions & 1 deletion assets/src/edit-story/elements/text/display.js
Expand Up @@ -125,9 +125,10 @@ function TextDisplay({
font,
fontWeight,
isItalic,
content,
},
]);
}, [font, fontWeight, isItalic, maybeEnqueueFontStyle]);
}, [font, fontWeight, isItalic, content, maybeEnqueueFontStyle]);

useTransformHandler(id, (transform) => {
const target = ref.current;
Expand Down
3 changes: 2 additions & 1 deletion assets/src/edit-story/elements/text/edit.js
Expand Up @@ -214,9 +214,10 @@ function TextEdit({
font,
fontWeight,
isItalic,
content,
},
]);
}, [font, fontWeight, isItalic, maybeEnqueueFontStyle]);
}, [font, fontWeight, isItalic, content, maybeEnqueueFontStyle]);

return (
<Wrapper ref={wrapperRef} onClick={onClick}>
Expand Down

0 comments on commit b7a18ba

Please sign in to comment.