fontdue-js 1.6.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +14 -5
- package/dist/components/BuyButton/index.d.ts +1 -0
- package/dist/components/BuyButton/index.js +2 -1
- package/dist/components/Root/index.js +2 -2
- package/dist/components/TypeTester/TypeTesterStandalone.d.ts +6 -6
- package/dist/components/TypeTester/TypeTesterStandalone.js +6 -8
- package/dist/components/TypeTester/TypeTesterStandaloneElement.d.ts +14 -0
- package/dist/components/TypeTester/TypeTesterStandaloneElement.js +50 -0
- package/dist/components/TypeTester/TypeTesterStyleSelectData.js +5 -1
- package/dist/components/TypeTester/index.d.ts +2 -2
- package/dist/components/TypeTester/index.js +1 -1
- package/dist/components/TypeTester/types.d.ts +1 -0
- package/dist/components/TypeTesters/TypeTestersElement.d.ts +11 -0
- package/dist/components/TypeTesters/TypeTestersElement.js +31 -0
- package/dist/components/TypeTesters/index.d.ts +3 -3
- package/dist/components/TypeTesters/index.js +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## 1.8.1
|
|
2
|
+
|
|
3
|
+
- Fixed BuyButton label rendering
|
|
4
|
+
|
|
5
|
+
## 1.8.0
|
|
6
|
+
|
|
7
|
+
- Added `label` property to BuyButton
|
|
8
|
+
- Updated markup for Type Tester name
|
|
9
|
+
- Corrected description of API for TypeTesters `tags` and `excludeTags` properties
|
|
10
|
+
|
|
11
|
+
## 1.7.0
|
|
12
|
+
|
|
13
|
+
- Updated `TypeTester` API for React and added documentation
|
|
14
|
+
|
|
1
15
|
## 1.6.0
|
|
2
16
|
|
|
3
17
|
- Added `CustomerLoginForm` component
|
package/README.md
CHANGED
|
@@ -79,6 +79,7 @@ import BuyButton from 'fontdue-js/BuyButton';
|
|
|
79
79
|
| --- | --- |
|
|
80
80
|
| `collectionId` or `collectionSlug` | (Required) `string` Collection identifier |
|
|
81
81
|
| `collectionName` | (Optional) `string` The name to render in the button: `Buy {collectionName}` |
|
|
82
|
+
| `label` | (Optional) `string` Label for the button (defaults to `Buy {collectionName}`) |
|
|
82
83
|
|
|
83
84
|
## `CartButton`
|
|
84
85
|
|
|
@@ -132,22 +133,30 @@ import TypeTesters from 'fontdue-js/TypeTesters';
|
|
|
132
133
|
| `collectionId` or `collectionSlug` | (Required) `string` Identifier for collection |
|
|
133
134
|
| `defaultMode` | (Optional) `'local' \| 'global'` The mode refers to the toggle in the UI: Affect all styles. `local` mode has this toggle turned off by default, `global` turns it on |
|
|
134
135
|
| `autofit` | (Optional) `boolean` Set to `true` to make the sentences fit on one line. It will adjust to the width of the tester as the user changes their browser window. If the user changes the font size or edits content, autofitting is turned off for that tester |
|
|
135
|
-
| `tags` | (Optional) `string[]` Will render only type testers that include
|
|
136
|
-
| `excludeTags` | (Optional) `string[]` Will exclude type testers that include
|
|
136
|
+
| `tags` | (Optional) `string[]` Will render only type testers that include these tags |
|
|
137
|
+
| `excludeTags` | (Optional) `string[]` Will exclude type testers that include these tags |
|
|
137
138
|
| `onFocus` | (Optional) `() => void` when any type tester is focused |
|
|
138
139
|
| `onBlur` | (Optional) `() => void` when any type tester is blurred |
|
|
139
140
|
| `onToolbarOpenClose` | (Optional) `(open: boolean) => void` Callback when toolbar is opened/closed |
|
|
140
141
|
|
|
141
|
-
## `TypeTester`
|
|
142
|
+
## `TypeTester` (standalone)
|
|
142
143
|
|
|
143
144
|
Standalone version of the type tester, which does not query the Fontdue CMS for content. You supply the content instead. Does not support the "Affect all styles" feature of the TypeTesters component.
|
|
144
145
|
|
|
145
|
-
The props accepted for this compnenent will change and be documented thereafter.
|
|
146
|
-
|
|
147
146
|
```tsx
|
|
148
147
|
import TypeTester from 'fontdue-js/TypeTester';
|
|
149
148
|
```
|
|
150
149
|
|
|
150
|
+
| Prop | Description |
|
|
151
|
+
| --- | --- |
|
|
152
|
+
| `familyName` | (Required) `string` Font family name (must have been already uploaded to your Fontdue admin) |
|
|
153
|
+
| `styleName` | (Required) `string` The name of the style from the family to display. |
|
|
154
|
+
| `fontSize` | (Optional) `number` Initial font size in pixels. |
|
|
155
|
+
| `lineHeight` | (Optional) `number` Line-height as a proportional value where `1 == fontSize`. |
|
|
156
|
+
| `content` | (Optional) `string` The initial content to display. |
|
|
157
|
+
| `features` | (Optional) `string[]` List of opentype feature codes to expose as options to users. (e.g. `['ss01', 'ss02']`) |
|
|
158
|
+
| `autofit` | (Optional) See `TypeTesters.autofit` above |
|
|
159
|
+
|
|
151
160
|
## `TestFontsForm`
|
|
152
161
|
|
|
153
162
|
Displays a form for users to enter their information and download test fonts. Make sure you have configured [Test Fonts](https://docs.fontdue.com/test-fonts) for this to work.
|
|
@@ -3,6 +3,7 @@ interface BuyButtonQueryRenderer_props {
|
|
|
3
3
|
collectionId?: string | null;
|
|
4
4
|
collectionSlug?: string | null;
|
|
5
5
|
collectionName?: string;
|
|
6
|
+
label?: string;
|
|
6
7
|
}
|
|
7
8
|
declare const BuyButtonQueryRenderer: React.FC<BuyButtonQueryRenderer_props>;
|
|
8
9
|
export default BuyButtonQueryRenderer;
|
|
@@ -28,6 +28,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
28
28
|
const BuyButtonBase = _ref => {
|
|
29
29
|
let {
|
|
30
30
|
collection,
|
|
31
|
+
label,
|
|
31
32
|
collectionName
|
|
32
33
|
} = _ref;
|
|
33
34
|
const store = (0, _reactRedux.useStore)();
|
|
@@ -67,7 +68,7 @@ const BuyButtonBase = _ref => {
|
|
|
67
68
|
className: "buy-button",
|
|
68
69
|
onClick: handleClick,
|
|
69
70
|
type: "button"
|
|
70
|
-
},
|
|
71
|
+
}, label ? label : `Buy ${collectionName !== null && collectionName !== void 0 ? collectionName : ''}`);
|
|
71
72
|
};
|
|
72
73
|
|
|
73
74
|
const BuyButton = (0, _reactRelay.createFragmentContainer)(BuyButtonBase, {
|
|
@@ -60,8 +60,8 @@ const customElementMap = {
|
|
|
60
60
|
'fontdue-sticky-nav': loadable(() => Promise.resolve().then(() => _interopRequireWildcard(require('../StickyNav')))),
|
|
61
61
|
'fontdue-store-modal': loadable(() => Promise.resolve().then(() => _interopRequireWildcard(require('../StoreModal')))),
|
|
62
62
|
'fontdue-test-fonts-form': loadable(() => Promise.resolve().then(() => _interopRequireWildcard(require('../TestFontsForm')))),
|
|
63
|
-
'fontdue-type-tester': loadable(() => Promise.resolve().then(() => _interopRequireWildcard(require('../TypeTester/
|
|
64
|
-
'fontdue-type-testers': loadable(() => Promise.resolve().then(() => _interopRequireWildcard(require('../TypeTesters'))))
|
|
63
|
+
'fontdue-type-tester': loadable(() => Promise.resolve().then(() => _interopRequireWildcard(require('../TypeTester/TypeTesterStandaloneElement')))),
|
|
64
|
+
'fontdue-type-testers': loadable(() => Promise.resolve().then(() => _interopRequireWildcard(require('../TypeTesters/TypeTestersElement'))))
|
|
65
65
|
};
|
|
66
66
|
Object.keys(customElementMap).forEach(elementName => {
|
|
67
67
|
// this might be more sophisticated in the future with a shadow DOM, etc,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Alignment } from './types';
|
|
2
|
+
import { Alignment, Direction } from './types';
|
|
3
3
|
interface TypeTesterStandalone {
|
|
4
4
|
familyName: string;
|
|
5
5
|
styleName: string;
|
|
6
|
-
lineHeight?:
|
|
7
|
-
fontSize?:
|
|
8
|
-
features?: string;
|
|
6
|
+
lineHeight?: number;
|
|
7
|
+
fontSize?: number;
|
|
8
|
+
features?: string[];
|
|
9
9
|
content?: string;
|
|
10
|
-
direction?:
|
|
10
|
+
direction?: Direction;
|
|
11
11
|
alignment?: Alignment;
|
|
12
|
-
autofit?:
|
|
12
|
+
autofit?: boolean;
|
|
13
13
|
onFocus?: () => void;
|
|
14
14
|
onBlur?: () => void;
|
|
15
15
|
}
|
|
@@ -19,8 +19,6 @@ var _TypeTesterStandalone_StyleQuery;
|
|
|
19
19
|
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
|
|
22
|
-
const parseBool = input => input === 'true' ? true : false;
|
|
23
|
-
|
|
24
22
|
const TypeTesterStandalone = _ref => {
|
|
25
23
|
let {
|
|
26
24
|
familyName,
|
|
@@ -44,7 +42,7 @@ const TypeTesterStandalone = _ref => {
|
|
|
44
42
|
},
|
|
45
43
|
environment: environment,
|
|
46
44
|
render: _ref2 => {
|
|
47
|
-
var _props$viewer$fontSty, _props$viewer, _props$viewer$fontSty2,
|
|
45
|
+
var _props$viewer$fontSty, _props$viewer, _props$viewer$fontSty2, _props$viewer$fontSty3, _props$viewer2, _props$viewer2$fontSt, _props$viewer2$fontSt2, _props$viewer2$fontSt3, _props$viewer3, _props$viewer3$fontSt, _props$viewer3$fontSt2;
|
|
48
46
|
|
|
49
47
|
let {
|
|
50
48
|
props
|
|
@@ -55,17 +53,17 @@ const TypeTesterStandalone = _ref => {
|
|
|
55
53
|
testers: {
|
|
56
54
|
standalone: {
|
|
57
55
|
content: content !== null && content !== void 0 ? content : 'The quick brown fox...',
|
|
58
|
-
autofit:
|
|
59
|
-
size: fontSize ?
|
|
60
|
-
lineHeight: lineHeight ?
|
|
56
|
+
autofit: autofit !== null && autofit !== void 0 ? autofit : false,
|
|
57
|
+
size: fontSize !== null && fontSize !== void 0 ? fontSize : 72,
|
|
58
|
+
lineHeight: lineHeight !== null && lineHeight !== void 0 ? lineHeight : 1,
|
|
61
59
|
alignment: alignment !== null && alignment !== void 0 ? alignment : 'left'
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
62
|
}, /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
65
63
|
id: "standalone",
|
|
66
64
|
fontStyleId: (_props$viewer$fontSty = (_props$viewer = props.viewer) === null || _props$viewer === void 0 ? void 0 : (_props$viewer$fontSty2 = _props$viewer.fontStyle) === null || _props$viewer$fontSty2 === void 0 ? void 0 : _props$viewer$fontSty2.id) !== null && _props$viewer$fontSty !== void 0 ? _props$viewer$fontSty : null,
|
|
67
|
-
features:
|
|
68
|
-
direction: direction
|
|
65
|
+
features: features,
|
|
66
|
+
direction: direction,
|
|
69
67
|
productId: (_props$viewer$fontSty3 = (_props$viewer2 = props.viewer) === null || _props$viewer2 === void 0 ? void 0 : (_props$viewer2$fontSt = _props$viewer2.fontStyle) === null || _props$viewer2$fontSt === void 0 ? void 0 : (_props$viewer2$fontSt2 = _props$viewer2$fontSt.family) === null || _props$viewer2$fontSt2 === void 0 ? void 0 : (_props$viewer2$fontSt3 = _props$viewer2$fontSt2.parent) === null || _props$viewer2$fontSt3 === void 0 ? void 0 : _props$viewer2$fontSt3.id) !== null && _props$viewer$fontSty3 !== void 0 ? _props$viewer$fontSty3 : (_props$viewer3 = props.viewer) === null || _props$viewer3 === void 0 ? void 0 : (_props$viewer3$fontSt = _props$viewer3.fontStyle) === null || _props$viewer3$fontSt === void 0 ? void 0 : (_props$viewer3$fontSt2 = _props$viewer3$fontSt.family) === null || _props$viewer3$fontSt2 === void 0 ? void 0 : _props$viewer3$fontSt2.id,
|
|
70
68
|
groupEdit: false,
|
|
71
69
|
onFocus: onFocus,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface TypeTesterElement_props {
|
|
3
|
+
familyName: string;
|
|
4
|
+
styleName: string;
|
|
5
|
+
lineHeight?: string;
|
|
6
|
+
fontSize?: string;
|
|
7
|
+
features?: string;
|
|
8
|
+
content?: string;
|
|
9
|
+
direction?: string;
|
|
10
|
+
alignment?: string;
|
|
11
|
+
autofit?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const TypeTesterStandaloneElement: React.FC<TypeTesterElement_props>;
|
|
14
|
+
export default TypeTesterStandaloneElement;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.TypeTesterStandaloneElement = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _TypeTesterStandalone = _interopRequireDefault(require("./TypeTesterStandalone"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
+
|
|
16
|
+
const isAlignment = str => {
|
|
17
|
+
return str === 'left' || str === 'center' || str === 'right';
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const isDirection = str => {
|
|
21
|
+
return str === 'ltr' || str === 'rtl';
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const parseBool = input => input === 'true' ? true : false;
|
|
25
|
+
|
|
26
|
+
const TypeTesterStandaloneElement = _ref => {
|
|
27
|
+
var _features$split;
|
|
28
|
+
|
|
29
|
+
let {
|
|
30
|
+
lineHeight,
|
|
31
|
+
fontSize,
|
|
32
|
+
features,
|
|
33
|
+
alignment,
|
|
34
|
+
direction,
|
|
35
|
+
autofit,
|
|
36
|
+
...rest
|
|
37
|
+
} = _ref;
|
|
38
|
+
return /*#__PURE__*/_react.default.createElement(_TypeTesterStandalone.default, _extends({
|
|
39
|
+
autofit: parseBool(autofit),
|
|
40
|
+
lineHeight: lineHeight ? parseFloat(lineHeight) : undefined,
|
|
41
|
+
fontSize: fontSize ? parseFloat(fontSize) : undefined,
|
|
42
|
+
features: (_features$split = features === null || features === void 0 ? void 0 : features.split(',')) !== null && _features$split !== void 0 ? _features$split : [],
|
|
43
|
+
alignment: isAlignment(alignment) ? alignment : undefined,
|
|
44
|
+
direction: isDirection(direction) ? direction : undefined
|
|
45
|
+
}, rest));
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.TypeTesterStandaloneElement = TypeTesterStandaloneElement;
|
|
49
|
+
var _default = TypeTesterStandaloneElement;
|
|
50
|
+
exports.default = _default;
|
|
@@ -76,7 +76,11 @@ const TypeTesterStyleSelectData = _ref => {
|
|
|
76
76
|
onSelectFamilyId: handleSelectFamilyId
|
|
77
77
|
}) : fontStyle.family && /*#__PURE__*/_react.default.createElement("div", {
|
|
78
78
|
className: "type-tester__name"
|
|
79
|
-
},
|
|
79
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
80
|
+
className: "type-tester__name__family"
|
|
81
|
+
}, fontStyle.family.name), ' ', /*#__PURE__*/_react.default.createElement("span", {
|
|
82
|
+
className: "type-tester__name__style"
|
|
83
|
+
}, fontStyle.name.replace(/ /g, '\xa0')));
|
|
80
84
|
};
|
|
81
85
|
|
|
82
86
|
var _default = (0, _reactRelay.createFragmentContainer)(TypeTesterStyleSelectData, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Alignment } from './types';
|
|
2
|
+
import { Alignment, Direction } from './types';
|
|
3
3
|
export interface TypeTesterConfig {
|
|
4
4
|
min?: number;
|
|
5
5
|
max?: number;
|
|
@@ -45,7 +45,7 @@ export interface TypeTesterConfig {
|
|
|
45
45
|
export interface TypeTesterBaseProps {
|
|
46
46
|
id: string;
|
|
47
47
|
productId?: string;
|
|
48
|
-
direction:
|
|
48
|
+
direction: Direction | undefined;
|
|
49
49
|
onSelectFontStyleId: (value: string) => void;
|
|
50
50
|
features?: readonly string[] | null;
|
|
51
51
|
groupEdit?: boolean;
|
|
@@ -4,4 +4,5 @@ export declare type Size = number;
|
|
|
4
4
|
export declare type LineHeight = number;
|
|
5
5
|
export declare type Features = string[];
|
|
6
6
|
export declare type Alignment = 'left' | 'center' | 'right';
|
|
7
|
+
export declare type Direction = 'ltr' | 'rtl';
|
|
7
8
|
export declare type TypeTesterMode = 'local' | 'group';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface TypeTestersElementProps {
|
|
3
|
+
collectionId?: string;
|
|
4
|
+
collectionSlug?: string;
|
|
5
|
+
defaultMode?: string;
|
|
6
|
+
autofit?: string;
|
|
7
|
+
tags?: string;
|
|
8
|
+
excludeTags?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const TypeTestersElement: React.FC<TypeTestersElementProps>;
|
|
11
|
+
export default TypeTestersElement;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _index = _interopRequireDefault(require("./index"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
+
|
|
16
|
+
const TypeTestersElement = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
autofit,
|
|
19
|
+
tags,
|
|
20
|
+
excludeTags,
|
|
21
|
+
...rest
|
|
22
|
+
} = _ref;
|
|
23
|
+
return /*#__PURE__*/_react.default.createElement(_index.default, _extends({
|
|
24
|
+
tags: tags === null || tags === void 0 ? void 0 : tags.split(','),
|
|
25
|
+
excludeTags: excludeTags === null || excludeTags === void 0 ? void 0 : excludeTags.split(','),
|
|
26
|
+
autofit: autofit === 'true'
|
|
27
|
+
}, rest));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var _default = TypeTestersElement;
|
|
31
|
+
exports.default = _default;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface TypeTestersQueryRendererProps {
|
|
3
|
-
collectionId?: string
|
|
4
|
-
collectionSlug?: string
|
|
3
|
+
collectionId?: string;
|
|
4
|
+
collectionSlug?: string;
|
|
5
5
|
defaultMode?: string;
|
|
6
|
-
autofit?:
|
|
6
|
+
autofit?: boolean;
|
|
7
7
|
precartOpen?: boolean;
|
|
8
8
|
tags?: string[];
|
|
9
9
|
excludeTags?: string[];
|
|
@@ -138,7 +138,7 @@ const TypeTesters = (0, _reactRelay.createFragmentContainer)(TypeTestersBase, {
|
|
|
138
138
|
});
|
|
139
139
|
|
|
140
140
|
const getDefaultMode = (stringValue, autofit) => {
|
|
141
|
-
if (autofit
|
|
141
|
+
if (autofit) return 'local';
|
|
142
142
|
if (stringValue === 'group') return 'group';
|
|
143
143
|
return 'local';
|
|
144
144
|
};
|
|
@@ -183,7 +183,7 @@ const TypeTestersQueryRenderer = _ref2 => {
|
|
|
183
183
|
defaultMode: getDefaultMode(defaultMode, autofit),
|
|
184
184
|
precartOpen: precartOpen,
|
|
185
185
|
includePriceBar: includePriceBar,
|
|
186
|
-
autofit: autofit
|
|
186
|
+
autofit: autofit !== null && autofit !== void 0 ? autofit : false,
|
|
187
187
|
onFocus: onFocus,
|
|
188
188
|
onBlur: onBlur,
|
|
189
189
|
onToolbarOpenClose: onToolbarOpenClose
|
|
@@ -218,7 +218,7 @@ const TypeTestersQueryRenderer = _ref2 => {
|
|
|
218
218
|
defaultMode: getDefaultMode(defaultMode, autofit),
|
|
219
219
|
precartOpen: precartOpen,
|
|
220
220
|
includePriceBar: includePriceBar,
|
|
221
|
-
autofit: autofit
|
|
221
|
+
autofit: autofit !== null && autofit !== void 0 ? autofit : false,
|
|
222
222
|
onFocus: onFocus,
|
|
223
223
|
onBlur: onBlur,
|
|
224
224
|
onToolbarOpenClose: onToolbarOpenClose
|