@expo/styleguide 8.0.0-alpha.5 → 8.0.0-alpha.7
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/README.md +3 -1
- package/dist/index.js +24 -4
- package/dist/src/components/Button/Button.d.ts +14 -1
- package/package.json +3 -2
- package/tailwind.js +16 -0
package/README.md
CHANGED
|
@@ -24,7 +24,9 @@ For the Styleguide we use our custom Tailwind theme, which is based on the defau
|
|
|
24
24
|
* only valid media screen scopes are: `xs:`, `sm:`, `md:`, `lg:` and `xl:`
|
|
25
25
|
* there is a custom `hocus:` scope which is a shorthand for hover and focus states
|
|
26
26
|
* typography elements are predefined as a `heading-[size]` styles sets
|
|
27
|
-
* `icon-[size]` are custom component classes defined for icons sizing
|
|
27
|
+
* `icon-[size]` are custom component classes defined for icons sizing
|
|
28
|
+
|
|
29
|
+
The theme can be extended, if needed, and includes `@tailwindcss/typography` plugin by default, with a stripped down version of default config.
|
|
28
30
|
|
|
29
31
|
## Development
|
|
30
32
|
|
package/dist/index.js
CHANGED
|
@@ -214,6 +214,7 @@ var ButtonBase = React.forwardRef(function (_a, ref) {
|
|
|
214
214
|
var children = _a.children, testID = _a.testID, className = _a.className, onClick = _a.onClick, _b = _a.type, type = _b === void 0 ? 'button' : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, rest = __rest(_a, ["children", "testID", "className", "onClick", "type", "disabled"]);
|
|
215
215
|
return (React.createElement("button", __assign({ className: mergeClasses('flex cursor-pointer', className), "data-testid": testID, disabled: disabled, ref: ref, type: type, onClick: disabled ? undefined : onClick }, rest), children));
|
|
216
216
|
});
|
|
217
|
+
ButtonBase.displayName = 'ButtonBase';
|
|
217
218
|
|
|
218
219
|
var STOPWORDS = 'a an and at but by for in nor of on or out so the to up with yet'.split(' ');
|
|
219
220
|
function titleCase(value, options) {
|
|
@@ -253,6 +254,7 @@ var LinkBase = React.forwardRef(function (_a, ref) {
|
|
|
253
254
|
}
|
|
254
255
|
return (React.createElement(Link$1, __assign({ href: href, ref: ref, onClick: onClick, target: openInNewTab ? '_blank' : target, rel: openInNewTab ? 'noopener noreferrer' : rel, "data-testid": testID }, rest), children));
|
|
255
256
|
});
|
|
257
|
+
LinkBase.displayName = 'LinkBase';
|
|
256
258
|
|
|
257
259
|
function Link(_a) {
|
|
258
260
|
var className = _a.className, disabled = _a.disabled, rest = __rest(_a, ["className", "disabled"]);
|
|
@@ -326,6 +328,22 @@ function getThemedIconClasses(theme) {
|
|
|
326
328
|
return 'text-button-quaternary-icon';
|
|
327
329
|
}
|
|
328
330
|
}
|
|
331
|
+
function getButtonIconClasses(size) {
|
|
332
|
+
switch (size) {
|
|
333
|
+
case 'xs':
|
|
334
|
+
return 'px-0 w-8 justify-center items-center';
|
|
335
|
+
case 'sm':
|
|
336
|
+
return 'px-0 w-9 justify-center items-center';
|
|
337
|
+
case 'md':
|
|
338
|
+
return 'px-0 w-10 justify-center items-center';
|
|
339
|
+
case 'lg':
|
|
340
|
+
return 'px-0 w-11 justify-center items-center';
|
|
341
|
+
case 'xl':
|
|
342
|
+
return 'px-0 w-12 justify-center items-center';
|
|
343
|
+
case '2xl':
|
|
344
|
+
return 'px-0 w-15 justify-center items-center';
|
|
345
|
+
}
|
|
346
|
+
}
|
|
329
347
|
function isIconElement(element) {
|
|
330
348
|
var _a, _b, _c;
|
|
331
349
|
if (React.isValidElement(element)) {
|
|
@@ -337,18 +355,20 @@ function isIconElement(element) {
|
|
|
337
355
|
function getIconProps(element, classNames) {
|
|
338
356
|
return __assign(__assign({}, element.props), { className: mergeClasses(classNames, element.props.className) });
|
|
339
357
|
}
|
|
340
|
-
var Button = function (
|
|
341
|
-
var children =
|
|
358
|
+
var Button = React.forwardRef(function (_a, ref) {
|
|
359
|
+
var children = _a.children, _b = _a.size, size = _b === void 0 ? 'sm' : _b, _c = _a.theme, theme = _c === void 0 ? 'primary' : _c, _d = _a.skipCapitalization, skipCapitalization = _d === void 0 ? false : _d, href = _a.href, disabled = _a.disabled, className = _a.className, leftSlot = _a.leftSlot, rightSlot = _a.rightSlot, openInNewTab = _a.openInNewTab, rest = __rest(_a, ["children", "size", "theme", "skipCapitalization", "href", "disabled", "className", "leftSlot", "rightSlot", "openInNewTab"]);
|
|
342
360
|
var Element = href ? LinkBase : ButtonBase;
|
|
343
361
|
var isLeftSlotIcon = leftSlot && isIconElement(leftSlot);
|
|
344
362
|
var isRightSlotIcon = rightSlot && isIconElement(rightSlot);
|
|
345
363
|
var iconClasses = (isLeftSlotIcon || isRightSlotIcon) &&
|
|
346
364
|
mergeClasses("".concat(getIconSizeClasses(size)), getThemedIconClasses(theme), disabled && 'opacity-60');
|
|
347
|
-
|
|
365
|
+
var isSingleIconButton = (leftSlot || rightSlot) && !children;
|
|
366
|
+
return (React.createElement(Element, __assign({ href: href, className: mergeClasses("inline-flex border border-solid rounded-md font-medium gap-2 items-center whitespace-nowrap transition", getSizeClasses(size), getThemeClasses(theme, disabled), isSingleIconButton && getButtonIconClasses(size), disabled && 'cursor-default opacity-80 pointer-event-none', className), disabled: disabled }, (href ? { openInNewTab: openInNewTab } : {}), rest),
|
|
348
367
|
isLeftSlotIcon ? React.cloneElement(leftSlot, getIconProps(leftSlot, iconClasses)) : leftSlot,
|
|
349
368
|
children && (React.createElement("span", { className: mergeClasses('flex self-center text-inherit leading-none', href && 'select-none') }, typeof children === 'string' && !skipCapitalization ? titleCase(children) : children)),
|
|
350
369
|
isRightSlotIcon ? React.cloneElement(rightSlot, getIconProps(rightSlot, iconClasses)) : rightSlot));
|
|
351
|
-
};
|
|
370
|
+
});
|
|
371
|
+
Button.displayName = 'Button';
|
|
352
372
|
|
|
353
373
|
function DocsLogo(_a) {
|
|
354
374
|
var className = _a.className, rest = __rest(_a, ["className"]);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { ReactElement } from 'react';
|
|
2
3
|
import { ButtonBaseProps } from './ButtonBase';
|
|
3
4
|
import { LinkBaseProps } from '../Link';
|
|
@@ -10,4 +11,16 @@ export type ButtonProps = ButtonBaseProps & LinkBaseProps & {
|
|
|
10
11
|
rightSlot?: ReactElement;
|
|
11
12
|
skipCapitalization?: boolean;
|
|
12
13
|
};
|
|
13
|
-
export declare const Button:
|
|
14
|
+
export declare const Button: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
15
|
+
testID?: string | undefined;
|
|
16
|
+
} & React.AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
17
|
+
testID?: string | undefined;
|
|
18
|
+
openInNewTab?: boolean | undefined;
|
|
19
|
+
disabled?: boolean | undefined;
|
|
20
|
+
} & {
|
|
21
|
+
size?: ButtonSize | undefined;
|
|
22
|
+
theme?: ButtonTheme | undefined;
|
|
23
|
+
leftSlot?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
24
|
+
rightSlot?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
25
|
+
skipCapitalization?: boolean | undefined;
|
|
26
|
+
} & React.RefAttributes<HTMLButtonElement | HTMLLinkElement>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/styleguide",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.7",
|
|
4
4
|
"description": "Expo's styleguide components for use on the web.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@rollup/plugin-typescript": "^11.0.0",
|
|
33
|
+
"@tailwindcss/typography": "^0.5.9",
|
|
33
34
|
"@types/react": "^18.0.28",
|
|
34
35
|
"npm-run-all": "^4.1.5",
|
|
35
36
|
"rimraf": "^4.1.2",
|
|
@@ -49,5 +50,5 @@
|
|
|
49
50
|
"eslintConfig": {
|
|
50
51
|
"extends": "universe/web"
|
|
51
52
|
},
|
|
52
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "62bbffc1d217d859b3baba05e2bf09b9ab257056"
|
|
53
54
|
}
|
package/tailwind.js
CHANGED
|
@@ -344,6 +344,9 @@ const expoTailwindConfig = {
|
|
|
344
344
|
height: {
|
|
345
345
|
15: '3.75rem',
|
|
346
346
|
},
|
|
347
|
+
width: {
|
|
348
|
+
15: '3.75rem',
|
|
349
|
+
},
|
|
347
350
|
opacity: {
|
|
348
351
|
inherit: 'inherit',
|
|
349
352
|
},
|
|
@@ -363,6 +366,18 @@ const expoTailwindConfig = {
|
|
|
363
366
|
transitionDuration: {
|
|
364
367
|
default: '150ms',
|
|
365
368
|
},
|
|
369
|
+
typography: () => ({
|
|
370
|
+
DEFAULT: {
|
|
371
|
+
css: {
|
|
372
|
+
sm: null,
|
|
373
|
+
base: null,
|
|
374
|
+
lg: null,
|
|
375
|
+
xl: null,
|
|
376
|
+
'2xl': null,
|
|
377
|
+
invert: null,
|
|
378
|
+
},
|
|
379
|
+
},
|
|
380
|
+
}),
|
|
366
381
|
},
|
|
367
382
|
},
|
|
368
383
|
corePlugins: {
|
|
@@ -404,6 +419,7 @@ const expoTailwindConfig = {
|
|
|
404
419
|
},
|
|
405
420
|
});
|
|
406
421
|
}),
|
|
422
|
+
require('@tailwindcss/typography'),
|
|
407
423
|
],
|
|
408
424
|
};
|
|
409
425
|
|