@codecademy/gamut-styles 17.13.2-alpha.d5be1a.0 → 17.13.2-alpha.dd8c42.0
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/dist/AssetProvider.d.ts +1 -1
- package/dist/AssetProvider.js +1 -1
- package/dist/globals/Typography.js +2 -2
- package/dist/remoteAssets/fonts.d.ts +1 -1
- package/dist/utilities/index.d.ts +0 -2
- package/dist/utilities/index.js +1 -3
- package/package.json +2 -2
- package/dist/utilities/directionIsRtl.d.ts +0 -14
- package/dist/utilities/directionIsRtl.js +0 -50
- package/dist/utilities/useLogicalProperties.d.ts +0 -8
- package/dist/utilities/useLogicalProperties.js +0 -13
- /package/dist/{utilities → utils}/fontUtils.d.ts +0 -0
- /package/dist/{utilities → utils}/fontUtils.js +0 -0
package/dist/AssetProvider.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Theme } from '@emotion/react';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { FontConfig } from './
|
|
3
|
+
import { FontConfig } from './utils/fontUtils';
|
|
4
4
|
export declare const createFontLinks: (fonts?: readonly FontConfig[]) => import("react/jsx-runtime").JSX.Element[];
|
|
5
5
|
export declare const AssetProvider: React.FC<{
|
|
6
6
|
theme?: Theme;
|
package/dist/AssetProvider.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { webFonts } from './remoteAssets/fonts';
|
|
3
3
|
import { coreTheme } from './themes';
|
|
4
|
-
import { getFonts } from './
|
|
4
|
+
import { getFonts } from './utils/fontUtils';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* Only preload woff2 fonts, since woff1 are only included as fallbacks.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { css, Global } from '@emotion/react';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { getFonts } from '../
|
|
3
|
+
import { getFonts } from '../utils/fontUtils';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Typography component that applies global typography styles to the application.
|
|
@@ -37,7 +37,7 @@ export const Typography = ({
|
|
|
37
37
|
weight = 'normal',
|
|
38
38
|
extensions,
|
|
39
39
|
filePath
|
|
40
|
-
}) => /*#__PURE__*/css("@font-face{font-display:swap;font-family:'", name, "';font-style:", style, ";font-weight:", weight, ";src:", extensions.map(ext => `url("${filePath}.${ext}") format("${ext}")`).join(', '), ";};label:typographyGlobals;" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
40
|
+
}) => /*#__PURE__*/css("@font-face{font-display:swap;font-family:'", name, "';font-style:", style, ";font-weight:", weight, ";src:", extensions.map(ext => `url("${filePath}.${ext}") format("${ext}")`).join(', '), ";};label:typographyGlobals;" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9nbG9iYWxzL1R5cG9ncmFwaHkudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQTZDNkIiLCJmaWxlIjoiLi4vLi4vc3JjL2dsb2JhbHMvVHlwb2dyYXBoeS50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBjc3MsIEdsb2JhbCB9IGZyb20gJ0BlbW90aW9uL3JlYWN0JztcbmltcG9ydCAqIGFzIFJlYWN0IGZyb20gJ3JlYWN0JztcblxuaW1wb3J0IHsgY29yZVRoZW1lIH0gZnJvbSAnLi4vdGhlbWVzJztcbmltcG9ydCB7IEZvbnRDb25maWcsIGdldEZvbnRzIH0gZnJvbSAnLi4vdXRpbHMvZm9udFV0aWxzJztcblxuLyoqXG4gKiBUeXBvZ3JhcGh5IGNvbXBvbmVudCB0aGF0IGFwcGxpZXMgZ2xvYmFsIHR5cG9ncmFwaHkgc3R5bGVzIHRvIHRoZSBhcHBsaWNhdGlvbi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kYXRhIHJlY2VpdmVkJyk7XG4gICAgICByZXR1cm4gbnVsbDtcbiAgICB9XG5cbiAgICBjb25zdCB0eXBvZ3JhcGh5R2xvYmFscyA9IGNzc2BcbiAgICAgICR7Zm9udHMubWFwKFxuICAgICAgICAoe1xuICAgICAgICAgIG5hbWUsXG4gICAgICAgICAgc3R5bGUgPSAnbm9ybWFsJyxcbiAgICAgICAgICB3ZWlnaHQgPSAnbm9ybWFsJyxcbiAgICAgICAgICBleHRlbnNpb25zLFxuICAgICAgICAgIGZpbGVQYXRoLFxuICAgICAgICB9OiBGb250Q29uZmlnKSA9PiBjc3NgXG4gICAgICAgICAgQGZvbnQtZmFjZSB7XG4gICAgICAgICAgICBmb250LWRpc3BsYXk6IHN3YXA7XG4gICAgICAgICAgICBmb250LWZhbWlseTogJyR7bmFtZX0nO1xuICAgICAgICAgICAgZm9udC1zdHlsZTogJHtzdHlsZX07XG4gICAgICAgICAgICBmb250LXdlaWdodDogJHt3ZWlnaHR9O1xuICAgICAgICAgICAgc3JjOiAke2V4dGVuc2lvbnNcbiAgICAgICAgICAgICAgLm1hcCgoZXh0KSA9PiBgdXJsKFwiJHtmaWxlUGF0aH0uJHtleHR9XCIpIGZvcm1hdChcIiR7ZXh0fVwiKWApXG4gICAgICAgICAgICAgIC5qb2luKCcsICcpfTtcbiAgICAgICAgICB9XG4gICAgICAgIGBcbiAgICAgICl9XG5cbiAgICAgIGgxLFxuICAgIGgyLFxuICAgIGgzLFxuICAgIGg0LFxuICAgIGg1LFxuICAgIGg2IHtcbiAgICAgICAgbWFyZ2luLWJvdHRvbTogJHt0aGVtZS5zcGFjaW5nWzE2XX07XG4gICAgICAgIGZvbnQtd2VpZ2h0OiAke3RoZW1lLmZvbnRXZWlnaHQudGl0bGV9O1xuICAgICAgICBsaW5lLWhlaWdodDogJHt0aGVtZS5saW5lSGVpZ2h0LnRpdGxlfTtcbiAgICAgIH1cblxuICAgICAgaDEge1xuICAgICAgICBmb250LXNpemU6ICR7dGhlbWUuZm9udFNpemVbNjRdfTtcbiAgICAgIH1cbiAgICAgIGgyIHtcbiAgICAgICAgZm9udC1zaXplOiAke3RoZW1lLmZvbnRTaXplWzQ0XX07XG4gICAgICB9XG4gICAgICBoMyB7XG4gICAgICAgIGZvbnQtc2l6ZTogJHt0aGVtZS5mb250U2l6ZVszNF19O1xuICAgICAgfVxuICAgICAgaDQge1xuICAgICAgICBmb250LXNpemU6ICR7dGhlbWUuZm9udFNpemVbMjZdfTtcbiAgICAgIH1cbiAgICAgIGg1IHtcbiAgICAgICAgZm9udC1zaXplOiAke3RoZW1lLmZvbnRTaXplWzIyXX07XG4gICAgICB9XG4gICAgICBoNiB7XG4gICAgICAgIGZvbnQtc2l6ZTogJHt0aGVtZS5mb250U2l6ZVsyMF19O1xuICAgICAgfVxuXG4gICAgICBzbWFsbCB7XG4gICAgICAgIGZvbnQtc2l6ZTogJHt0aGVtZS5mb250U2l6ZVsxNF19O1xuICAgICAgICBmb250LXdlaWdodDogJHt0aGVtZS5mb250V2VpZ2h0LmJhc2V9O1xuICAgICAgfVxuICAgIGA7XG5cbiAgICByZXR1cm4gPEdsb2JhbCBzdHlsZXM9e3R5cG9ncmFwaHlHbG9iYWxzfSAvPjtcbiAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICAvLyBIYW5kbGUgZm9udCBsb2FkaW5nIGVycm9ycyBncmFjZWZ1bGx5XG4gICAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIG5vLWNvbnNvbGVcbiAgICBjb25zb2xlLndhcm4oJ1R5cG9ncmFwaHk6IEZvbnQgbG9hZGluZyBmYWlsZWQ6JywgZXJyb3IpO1xuICAgIHJldHVybiBudWxsO1xuICB9XG59O1xuIl19 */"))), " h1,h2,h3,h4,h5,h6{margin-bottom:", theme.spacing[16], ";font-weight:", theme.fontWeight.title, ";line-height:", theme.lineHeight.title, ";}h1{font-size:", theme.fontSize[64], ";}h2{font-size:", theme.fontSize[44], ";}h3{font-size:", theme.fontSize[34], ";}h4{font-size:", theme.fontSize[26], ";}h5{font-size:", theme.fontSize[22], ";}h6{font-size:", theme.fontSize[20], ";}small{font-size:", theme.fontSize[14], ";font-weight:", theme.fontWeight.base, ";};label:typographyGlobals;" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9nbG9iYWxzL1R5cG9ncmFwaHkudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXFDaUMiLCJmaWxlIjoiLi4vLi4vc3JjL2dsb2JhbHMvVHlwb2dyYXBoeS50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBjc3MsIEdsb2JhbCB9IGZyb20gJ0BlbW90aW9uL3JlYWN0JztcbmltcG9ydCAqIGFzIFJlYWN0IGZyb20gJ3JlYWN0JztcblxuaW1wb3J0IHsgY29yZVRoZW1lIH0gZnJvbSAnLi4vdGhlbWVzJztcbmltcG9ydCB7IEZvbnRDb25maWcsIGdldEZvbnRzIH0gZnJvbSAnLi4vdXRpbHMvZm9udFV0aWxzJztcblxuLyoqXG4gKiBUeXBvZ3JhcGh5IGNvbXBvbmVudCB0aGF0IGFwcGxpZXMgZ2xvYmFsIHR5cG9ncmFwaHkgc3R5bGVzIHRvIHRoZSBhcHBsaWNhdGlvbi5cbiAqXG4gKiBUaGlzIGNvbXBvbmVudCBnZW5lcmF0ZXMgQ1NTLWluLUpTIHN0eWxlcyBmb3I6XG4gKiAtIEZvbnQgZmFjZSBkZWNsYXJhdGlvbnMgZm9yIGFsbCBjb25maWd1cmVkIGZvbnRzXG4gKiAtIEdsb2JhbCBoZWFkaW5nIHN0eWxlcyAoaDEtaDYpIHdpdGggdGhlbWUtYmFzZWQgc2l6aW5nIGFuZCBzcGFjaW5nXG4gKiAtIFNtYWxsIHRleHQgc3R5bGluZ1xuICpcbiAqIEBwYXJhbSBwcm9wcyAtIENvbXBvbm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A9PiBjc3NgXG4gICAgICAgICAgQGZvbnQtZmFjZSB7XG4gICAgICAgICAgICBmb250LWRpc3BsYXk6IHN3YXA7XG4gICAgICAgICAgICBmb250LWZhbWlseTogJyR7bmFtZX0nO1xuICAgICAgICAgICAgZm9udC1zdHlsZTogJHtzdHlsZX07XG4gICAgICAgICAgICBmb250LXdlaWdodDogJHt3ZWlnaHR9O1xuICAgICAgICAgICAgc3JjOiAke2V4dGVuc2lvbnNcbiAgICAgICAgICAgICAgLm1hcCgoZXh0KSA9PiBgdXJsKFwiJHtmaWxlUGF0aH0uJHtleHR9XCIpIGZvcm1hdChcIiR7ZXh0fVwiKWApXG4gICAgICAgICAgICAgIC5qb2luKCcsICcpfTtcbiAgICAgICAgICB9XG4gICAgICAgIGBcbiAgICAgICl9XG5cbiAgICAgIGgxLFxuICAgIGgyLFxuICAgIGgzLFxuICAgIGg0LFxuICAgIGg1LFxuICAgIGg2IHtcbiAgICAgICAgbWFyZ2luLWJvdHRvbTogJHt0aGVtZS5zcGFjaW5nWzE2XX07XG4gICAgICAgIGZvbnQtd2VpZ2h0OiAke3RoZW1lLmZvbnRXZWlnaHQudGl0bGV9O1xuICAgICAgICBsaW5lLWhlaWdodDogJHt0aGVtZS5saW5lSGVpZ2h0LnRpdGxlfTtcbiAgICAgIH1cblxuICAgICAgaDEge1xuICAgICAgICBmb250LXNpemU6ICR7dGhlbWUuZm9udFNpemVbNjRdfTtcbiAgICAgIH1cbiAgICAgIGgyIHtcbiAgICAgICAgZm9udC1zaXplOiAke3RoZW1lLmZvbnRTaXplWzQ0XX07XG4gICAgICB9XG4gICAgICBoMyB7XG4gICAgICAgIGZvbnQtc2l6ZTogJHt0aGVtZS5mb250U2l6ZVszNF19O1xuICAgICAgfVxuICAgICAgaDQge1xuICAgICAgICBmb250LXNpemU6ICR7dGhlbWUuZm9udFNpemVbMjZdfTtcbiAgICAgIH1cbiAgICAgIGg1IHtcbiAgICAgICAgZm9udC1zaXplOiAke3RoZW1lLmZvbnRTaXplWzIyXX07XG4gICAgICB9XG4gICAgICBoNiB7XG4gICAgICAgIGZvbnQtc2l6ZTogJHt0aGVtZS5mb250U2l6ZVsyMF19O1xuICAgICAgfVxuXG4gICAgICBzbWFsbCB7XG4gICAgICAgIGZvbnQtc2l6ZTogJHt0aGVtZS5mb250U2l6ZVsxNF19O1xuICAgICAgICBmb250LXdlaWdodDogJHt0aGVtZS5mb250V2VpZ2h0LmJhc2V9O1xuICAgICAgfVxuICAgIGA7XG5cbiAgICByZXR1cm4gPEdsb2JhbCBzdHlsZXM9e3R5cG9ncmFwaHlHbG9iYWxzfSAvPjtcbiAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICAvLyBIYW5kbGUgZm9udCBsb2FkaW5nIGVycm9ycyBncmFjZWZ1bGx5XG4gICAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIG5vLWNvbnNvbGVcbiAgICBjb25zb2xlLndhcm4oJ1R5cG9ncmFwaHk6IEZvbnQgbG9hZGluZyBmYWlsZWQ6JywgZXJyb3IpO1xuICAgIHJldHVybiBudWxsO1xuICB9XG59O1xuIl19 */"));
|
|
41
41
|
return /*#__PURE__*/_jsx(Global, {
|
|
42
42
|
styles: typographyGlobals
|
|
43
43
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FontConfig } from '../
|
|
1
|
+
import { FontConfig } from '../utils/fontUtils';
|
|
2
2
|
export declare const FONT_ASSET_PATH = "https://www.codecademy.com/gamut";
|
|
3
3
|
export declare const core: readonly FontConfig[];
|
|
4
4
|
export declare const percipio: readonly FontConfig[];
|
package/dist/utilities/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecademy/gamut-styles",
|
|
3
3
|
"description": "Styleguide & Component library for codecademy.com",
|
|
4
|
-
"version": "17.13.2-alpha.
|
|
4
|
+
"version": "17.13.2-alpha.dd8c42.0",
|
|
5
5
|
"author": "Jake Hiller <jake@codecademy.com>",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@codecademy/variance": "0.26.2-alpha.
|
|
7
|
+
"@codecademy/variance": "0.26.2-alpha.dd8c42.0",
|
|
8
8
|
"@emotion/is-prop-valid": "^1.1.0",
|
|
9
9
|
"framer-motion": "^11.18.0",
|
|
10
10
|
"get-nonce": "^1.0.0",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { RefObject } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Resolves whether layout direction is RTL for an element, including JSDOM where
|
|
4
|
-
* `getComputedStyle(el).direction` is often empty while `dir` is set on the root.
|
|
5
|
-
*/
|
|
6
|
-
export declare function directionIsRtl(el: Element): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Returns whether the resolved element’s direction is RTL, and updates when `dir`
|
|
9
|
-
* changes on the document subtree or after layout (so `ref.current` is current).
|
|
10
|
-
* Resolution uses {@link directionIsRtl}.
|
|
11
|
-
*
|
|
12
|
-
* @param elementRef - Optional ref; when missing or `current` is not an `Element`, uses `document.documentElement`.
|
|
13
|
-
*/
|
|
14
|
-
export declare function useDirectionIsRtl(elementRef?: RefObject<Element | null>): boolean;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { useEffect, useLayoutEffect, useReducer } from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Resolves whether layout direction is RTL for an element, including JSDOM where
|
|
5
|
-
* `getComputedStyle(el).direction` is often empty while `dir` is set on the root.
|
|
6
|
-
*/
|
|
7
|
-
export function directionIsRtl(el) {
|
|
8
|
-
const ownDir = el.getAttribute('dir');
|
|
9
|
-
if (ownDir === 'rtl') return true;
|
|
10
|
-
if (ownDir === 'ltr') return false;
|
|
11
|
-
const {
|
|
12
|
-
direction
|
|
13
|
-
} = getComputedStyle(el);
|
|
14
|
-
if (direction === 'rtl' || direction === 'ltr') {
|
|
15
|
-
return direction === 'rtl';
|
|
16
|
-
}
|
|
17
|
-
return document.documentElement.getAttribute('dir') === 'rtl';
|
|
18
|
-
}
|
|
19
|
-
function resolveElement(elementRef) {
|
|
20
|
-
return elementRef?.current instanceof Element ? elementRef.current : document.documentElement;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Returns whether the resolved element’s direction is RTL, and updates when `dir`
|
|
25
|
-
* changes on the document subtree or after layout (so `ref.current` is current).
|
|
26
|
-
* Resolution uses {@link directionIsRtl}.
|
|
27
|
-
*
|
|
28
|
-
* @param elementRef - Optional ref; when missing or `current` is not an `Element`, uses `document.documentElement`.
|
|
29
|
-
*/
|
|
30
|
-
export function useDirectionIsRtl(elementRef) {
|
|
31
|
-
const [, bump] = useReducer(n => n + 1, 0);
|
|
32
|
-
useLayoutEffect(() => {
|
|
33
|
-
bump();
|
|
34
|
-
}, [elementRef]);
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
const observer = new MutationObserver(() => {
|
|
37
|
-
bump();
|
|
38
|
-
});
|
|
39
|
-
observer.observe(document.documentElement, {
|
|
40
|
-
attributeFilter: ['dir'],
|
|
41
|
-
attributes: true,
|
|
42
|
-
subtree: true
|
|
43
|
-
});
|
|
44
|
-
return () => observer.disconnect();
|
|
45
|
-
}, []);
|
|
46
|
-
if (typeof document === 'undefined') {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
return directionIsRtl(resolveElement(elementRef));
|
|
50
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Whether Gamut system props emit logical CSS properties (`marginInlineStart`, etc.)
|
|
3
|
-
* vs physical (`marginLeft`, etc.). Matches `@codecademy/variance` when the theme
|
|
4
|
-
* omits the field: `theme.useLogicalProperties ?? true`.
|
|
5
|
-
*
|
|
6
|
-
* `GamutProvider` always merges an explicit boolean (default `false`).
|
|
7
|
-
*/
|
|
8
|
-
export declare function useLogicalProperties(): boolean;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { useTheme } from '@emotion/react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Whether Gamut system props emit logical CSS properties (`marginInlineStart`, etc.)
|
|
5
|
-
* vs physical (`marginLeft`, etc.). Matches `@codecademy/variance` when the theme
|
|
6
|
-
* omits the field: `theme.useLogicalProperties ?? true`.
|
|
7
|
-
*
|
|
8
|
-
* `GamutProvider` always merges an explicit boolean (default `false`).
|
|
9
|
-
*/
|
|
10
|
-
export function useLogicalProperties() {
|
|
11
|
-
const theme = useTheme();
|
|
12
|
-
return theme.useLogicalProperties ?? true;
|
|
13
|
-
}
|
|
File without changes
|
|
File without changes
|