@mackin.com/styleguide 8.2.3 → 8.3.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.
Files changed (3) hide show
  1. package/index.d.ts +8 -2
  2. package/index.js +131 -104
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -86,7 +86,7 @@ declare const Backdrop: (p: {
86
86
  __debug?: boolean;
87
87
  }) => JSX.Element;
88
88
 
89
- declare type ButtonVariant = 'label' | 'circle' | 'icon' | 'link' | 'inlineLink' | 'primary' | 'secondary' | 'omg' | 'primary2' | 'positive' | 'negative';
89
+ declare type ButtonVariant = 'label' | 'circle' | 'icon' | 'link' | 'inlineLink' | 'primary' | 'secondary' | 'omg' | 'primary2' | 'positive' | 'negative' | 'text';
90
90
  interface ButtonProps extends React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
91
91
  variant?: ButtonVariant;
92
92
  /** As round as can be. */
@@ -254,6 +254,7 @@ declare const ICONS: {
254
254
  };
255
255
  declare const Icon: (props: {
256
256
  id: string;
257
+ title?: string | undefined;
257
258
  className?: string | undefined;
258
259
  spin?: boolean | undefined;
259
260
  style?: React.CSSProperties | undefined;
@@ -432,6 +433,8 @@ declare const List: React.ForwardRefExoticComponent<Pick<ListProps, "altRowColor
432
433
  interface ListItemProps extends React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement> {
433
434
  /** For variant 'full', the content will take up the entire space of the parent (no padding applied by this component). */
434
435
  variant?: 'full';
436
+ /** By default (and not a good idea in hindsight), ListItem applies styles to child Button or OmniLink elements when the variant is 'full'. Use this to remove these styles. */
437
+ noContentStyling?: boolean;
435
438
  }
436
439
  declare const ListItem: (props: ListItemProps) => JSX.Element;
437
440
 
@@ -445,10 +448,13 @@ interface ModalProps {
445
448
  noBackground?: boolean;
446
449
  closeButton?: boolean;
447
450
  heading?: string;
451
+ /** Use to override default heading styling. */
452
+ headerClassName?: string;
448
453
  /** Selector of the element to focus on initial show. */
449
454
  focusSelector?: string;
450
455
  scrollable?: boolean;
451
456
  id?: string;
457
+ /** Applied to the modal body. */
452
458
  className?: string;
453
459
  __debug?: boolean;
454
460
  onClick?: () => void;
@@ -1039,7 +1045,7 @@ interface LinkProps extends LinkContentProps, React.DetailedHTMLProps<React.Anch
1039
1045
  /** Full width with max space between the text and the icon */
1040
1046
  iconBlock?: boolean;
1041
1047
  /** Corresponds to the button variants of the same name. */
1042
- variant?: 'button' | 'label' | 'icon' | 'circle' | 'primary' | 'secondary' | 'omg' | 'primary2' | 'positive' | 'negative';
1048
+ variant?: 'button' | 'label' | 'icon' | 'circle' | 'primary' | 'secondary' | 'omg' | 'primary2' | 'positive' | 'negative' | 'text';
1043
1049
  /** Only for button variants. */
1044
1050
  round?: boolean;
1045
1051
  /** Only for button variants. */
package/index.js CHANGED
@@ -67,7 +67,7 @@ function __rest(s, e) {
67
67
  return t;
68
68
  }
69
69
 
70
- //TB: will need to update. the versions of fa are at 6 now.
70
+ //TB: FUTURE will need to update. the versions of fa are at 6 now.
71
71
  // major version
72
72
  const ICONS = {
73
73
  add: proSolidSvgIcons.faPlus,
@@ -107,7 +107,7 @@ const ICONS = {
107
107
  const Icon = (props) => {
108
108
  var _a;
109
109
  const icon = (_a = ICONS[props.id]) !== null && _a !== void 0 ? _a : ICONS['noIcon'];
110
- return React__namespace.createElement(reactFontawesome.FontAwesomeIcon, { style: props.style, onClick: props.onClick, spin: props.spin, className: css.cx('icon', props.className), icon: icon });
110
+ return React__namespace.createElement(reactFontawesome.FontAwesomeIcon, { title: props.title, style: props.style, onClick: props.onClick, spin: props.spin, className: css.cx('icon', props.className), icon: icon });
111
111
  };
112
112
 
113
113
  /** Call this on your theme after messing with the props. It will re-build things that depend on sizes and colors. */
@@ -238,9 +238,70 @@ const useThemeSafely = () => {
238
238
  return defaultTheme;
239
239
  };
240
240
 
241
+ const getTagStyles = (theme, tag) => {
242
+ switch (tag) {
243
+ case 'p': return {
244
+ marginTop: theme.controls.paragraphPadding,
245
+ marginBottom: theme.controls.paragraphPadding
246
+ };
247
+ case 'h1': return {
248
+ fontSize: theme.fonts.sizeH1
249
+ };
250
+ case 'h2': return {
251
+ fontSize: theme.fonts.sizeH2
252
+ };
253
+ case 'h3': return {
254
+ fontSize: theme.fonts.sizeH3
255
+ };
256
+ case 'h4': return {
257
+ fontSize: theme.fonts.sizeH4
258
+ };
259
+ default: return undefined;
260
+ }
261
+ };
262
+ const headerRegex = /h1|h2|h3|h4/;
263
+ const alignStyles = {
264
+ 'center': { textAlign: 'center' },
265
+ 'left': { textAlign: 'left' },
266
+ 'right': { textAlign: 'right' }
267
+ };
268
+ /** Wraps common needs for displaying text. Use for all text-containing elements to save on duplicated styling. */
269
+ const Text = (props) => {
270
+ var _a, _b;
271
+ const theme = useThemeSafely();
272
+ const tagChoice = props.tag || 'p';
273
+ const style = props.style || {};
274
+ if (props.lineClamp) {
275
+ style.WebkitLineClamp = props.lineClamp;
276
+ }
277
+ if (props.leftPad) {
278
+ style.paddingLeft = props.leftPad;
279
+ }
280
+ const styles = css.css(getTagStyles(theme, tagChoice), {
281
+ userSelect: 'text',
282
+ label: 'Text',
283
+ fontSize: props.fontSize ? props.fontSize : undefined
284
+ }, alignStyles[(_a = props.align) !== null && _a !== void 0 ? _a : 'left'], props.smaller && { fontSize: theme.fonts.sizeSmall }, props.larger && { fontSize: theme.fonts.sizeLarge }, props.italics && { fontStyle: 'italic' }, props.ellipsis && {
285
+ overflow: 'hidden',
286
+ whiteSpace: 'nowrap',
287
+ textOverflow: 'ellipsis'
288
+ }, props.lineClamp && {
289
+ WebkitBoxOrient: 'vertical',
290
+ overflow: 'hidden',
291
+ textOverflow: 'ellipsis',
292
+ display: '-webkit-box'
293
+ }, props.spacedOut && { lineHeight: '1.5rem' }, props.bold && { fontWeight: 'bold' }, props.noPad && { margin: 0, padding: 0 }, headerRegex.test((_b = props.tag) !== null && _b !== void 0 ? _b : '') && {
294
+ fontFamily: theme.fonts.headerFamily
295
+ });
296
+ return React__namespace.createElement(tagChoice, {
297
+ style: style,
298
+ className: css.cx('text', styles, props.className)
299
+ }, props.children);
300
+ };
301
+
241
302
  const Button = React__namespace.forwardRef((props, ref) => {
242
303
  var _a;
243
- const nativeProps = __rest(props, ["variant", "round", "rightIcon", "leftIcon", "iconBlock", "small", "readOnly", "waiting", "enforceMinWidth", "controlAlign"]);
304
+ const { variant, round, rightIcon, leftIcon, iconBlock, small, readOnly, waiting, enforceMinWidth, controlAlign } = props, nativeProps = __rest(props, ["variant", "round", "rightIcon", "leftIcon", "iconBlock", "small", "readOnly", "waiting", "enforceMinWidth", "controlAlign"]);
244
305
  const theme = useThemeSafely();
245
306
  const buttonStyles = css.css `
246
307
  padding-left: ${theme.controls.padding};
@@ -307,11 +368,22 @@ const Button = React__namespace.forwardRef((props, ref) => {
307
368
  font-size: 1.3rem;
308
369
  `}
309
370
  `}
310
- ${props.variant === 'label' && `
371
+ ${(props.variant === 'label') && `
372
+ display: inline-block;
373
+ width: auto;
374
+ box-shadow: none;
375
+ border: none;
376
+ `}
377
+ ${(props.variant === 'text') && `
378
+ cursor: auto;
311
379
  display: inline-block;
312
380
  width: auto;
313
381
  box-shadow: none;
314
382
  border: none;
383
+ line-height: ${theme.controls.height};
384
+ &:hover:not(:disabled) {
385
+ filter: none;
386
+ }
315
387
  `}
316
388
  ${props.variant === 'link' && `
317
389
  padding: 0;
@@ -402,18 +474,24 @@ const Button = React__namespace.forwardRef((props, ref) => {
402
474
  `}
403
475
  `;
404
476
  const disabled = props.disabled || props.waiting;
405
- const button = (React__namespace.createElement("button", Object.assign({}, nativeProps, { ref: ref, disabled: disabled, className: css.cx('button', styles, props.className), type: (_a = props.type) !== null && _a !== void 0 ? _a : 'button' }),
406
- props.leftIcon && React__namespace.createElement("span", { className: css.css({ marginRight: '0.5rem' }) }, props.leftIcon),
407
- props.waiting ? React__namespace.createElement(Icon, { id: "waiting", spin: true }) : props.children,
408
- props.rightIcon && React__namespace.createElement("span", { className: css.css({ marginLeft: '0.5rem' }) }, props.rightIcon)));
477
+ let content;
478
+ if (variant === 'text') {
479
+ content = React__namespace.createElement(Text, { className: css.cx(styles, props.className), tag: "div" }, props.children);
480
+ }
481
+ else {
482
+ content = (React__namespace.createElement("button", Object.assign({}, nativeProps, { ref: ref, disabled: disabled, className: css.cx('button', styles, props.className), type: (_a = props.type) !== null && _a !== void 0 ? _a : 'button' }),
483
+ props.leftIcon && React__namespace.createElement("span", { className: css.css({ marginRight: '0.5rem' }) }, props.leftIcon),
484
+ props.waiting ? React__namespace.createElement(Icon, { id: "waiting", spin: true }) : props.children,
485
+ props.rightIcon && React__namespace.createElement("span", { className: css.css({ marginLeft: '0.5rem' }) }, props.rightIcon)));
486
+ }
409
487
  if (props.controlAlign) {
410
488
  return (React__namespace.createElement("span", { className: css.css({
411
489
  display: 'inline-block',
412
490
  width: '100%',
413
491
  paddingBottom: theme.controls.inputErrorMinHeight
414
- }) }, button));
492
+ }) }, content));
415
493
  }
416
- return button;
494
+ return content;
417
495
  });
418
496
 
419
497
  const accordianExpandTimeMs = 250;
@@ -726,30 +804,30 @@ const ListItem = (props) => {
726
804
  border-bottom: none;
727
805
  }
728
806
  `;
729
- const contentStyle = css.css `
730
- padding: calc(${theme.controls.padding} * 1.5);
731
- ${props.variant === 'full' && `
732
- padding:0;
733
- >.button {
734
- padding: calc(${theme.controls.padding} * 1.5);
735
- width: 100%;
736
- border: none;
737
- }
738
- >.omniLink {
739
- padding-left: calc(${theme.controls.padding} * 1.5);
740
- padding-right: calc(${theme.controls.padding} * 1.5);
741
- width: 100%;
742
- line-height: ${theme.controls.height};
743
- border: none;
744
- }
745
- >.button:not(:focus), >.omniLink:not(:focus) {
746
- box-shadow: none;
747
- }
748
- >.omniLink:not(.omniLink--iconBlock){
749
- display: block;
750
- }
751
- `}
752
- `;
807
+ const contentStyle = css.css({
808
+ padding: `calc(${theme.controls.padding} * 1.5)`
809
+ }, props.variant === 'full' && {
810
+ padding: 0
811
+ }, !props.noContentStyling && {
812
+ '>.button': {
813
+ padding: `calc(${theme.controls.padding} * 1.5)`,
814
+ width: '100%',
815
+ border: 'none'
816
+ },
817
+ '>.omniLink': {
818
+ paddingLeft: `calc(${theme.controls.padding} * 1.5)`,
819
+ paddingRight: `calc(${theme.controls.padding} * 1.5)`,
820
+ width: '100%',
821
+ border: 'none',
822
+ lineHeight: theme.controls.height
823
+ },
824
+ '>.button:not(:focus), >.omniLink:not(:focus)': {
825
+ boxShadow: 'none',
826
+ },
827
+ '>.omniLink:not(.omniLink--iconBlock)': {
828
+ display: 'block'
829
+ }
830
+ });
753
831
  return (React__namespace.createElement("li", Object.assign({}, liProps, { className: css.cx('listItem', itemStyles, props.className) }),
754
832
  React__namespace.createElement("div", { className: css.css(contentStyle) }, props.children)));
755
833
  };
@@ -785,67 +863,6 @@ const TabLocker = (props) => {
785
863
  } }, props.children));
786
864
  };
787
865
 
788
- const getTagStyles = (theme, tag) => {
789
- switch (tag) {
790
- case 'p': return {
791
- marginTop: theme.controls.paragraphPadding,
792
- marginBottom: theme.controls.paragraphPadding
793
- };
794
- case 'h1': return {
795
- fontSize: theme.fonts.sizeH1
796
- };
797
- case 'h2': return {
798
- fontSize: theme.fonts.sizeH2
799
- };
800
- case 'h3': return {
801
- fontSize: theme.fonts.sizeH3
802
- };
803
- case 'h4': return {
804
- fontSize: theme.fonts.sizeH4
805
- };
806
- default: return undefined;
807
- }
808
- };
809
- const headerRegex = /h1|h2|h3|h4/;
810
- const alignStyles = {
811
- 'center': { textAlign: 'center' },
812
- 'left': { textAlign: 'left' },
813
- 'right': { textAlign: 'right' }
814
- };
815
- /** Wraps common needs for displaying text. Use for all text-containing elements to save on duplicated styling. */
816
- const Text = (props) => {
817
- var _a, _b;
818
- const theme = useThemeSafely();
819
- const tagChoice = props.tag || 'p';
820
- const style = props.style || {};
821
- if (props.lineClamp) {
822
- style.WebkitLineClamp = props.lineClamp;
823
- }
824
- if (props.leftPad) {
825
- style.paddingLeft = props.leftPad;
826
- }
827
- const styles = css.css(getTagStyles(theme, tagChoice), {
828
- userSelect: 'text',
829
- label: 'Text',
830
- fontSize: props.fontSize ? props.fontSize : undefined
831
- }, alignStyles[(_a = props.align) !== null && _a !== void 0 ? _a : 'left'], props.smaller && { fontSize: theme.fonts.sizeSmall }, props.larger && { fontSize: theme.fonts.sizeLarge }, props.italics && { fontStyle: 'italic' }, props.ellipsis && {
832
- overflow: 'hidden',
833
- whiteSpace: 'nowrap',
834
- textOverflow: 'ellipsis'
835
- }, props.lineClamp && {
836
- WebkitBoxOrient: 'vertical',
837
- overflow: 'hidden',
838
- textOverflow: 'ellipsis',
839
- display: '-webkit-box'
840
- }, props.spacedOut && { lineHeight: '1.5rem' }, props.bold && { fontWeight: 'bold' }, props.noPad && { margin: 0, padding: 0 }, headerRegex.test((_b = props.tag) !== null && _b !== void 0 ? _b : '') && {
841
- fontFamily: theme.fonts.headerFamily
842
- });
843
- return React__namespace.createElement(tagChoice, {
844
- style: style,
845
- className: css.cx('text', styles, props.className)
846
- }, props.children);
847
- };
848
-
849
866
  //TB: FUTURE will need to use the new input
850
867
  const defaultMaxShownValues = 7;
851
868
  const buttonMarkerClass = 'ListItem__button';
@@ -1556,14 +1573,14 @@ const Modal = (p) => {
1556
1573
  outline: 'none'
1557
1574
  }
1558
1575
  });
1559
- const modalHeaderStyles = css.css({
1576
+ const modalHeaderStyles = css.cx(css.css({
1560
1577
  display: 'flex',
1561
1578
  justifyContent: 'space-between',
1562
1579
  alignItems: 'center',
1563
1580
  backgroundColor: theme.colors.header,
1564
1581
  padding: '1rem',
1565
1582
  color: theme.colors.headerFont
1566
- });
1583
+ }), p.headerClassName);
1567
1584
  const modalContainerStyles = css.css([{
1568
1585
  position: 'fixed',
1569
1586
  height: '100%',
@@ -3070,6 +3087,11 @@ const generateLinkStyles = (props, theme) => {
3070
3087
  box-shadow: none;
3071
3088
  border: none;
3072
3089
  `}
3090
+ ${props.variant === 'text' && `
3091
+ box-shadow: none;
3092
+ border: none;
3093
+ cursor: auto;
3094
+ `}
3073
3095
  ${props.variant === 'icon' && `
3074
3096
  box-shadow: none;
3075
3097
  border: none;
@@ -3099,10 +3121,13 @@ const generateLinkStyles = (props, theme) => {
3099
3121
  };
3100
3122
 
3101
3123
  const OmniLink = (props) => {
3102
- const linkProps = __rest(props, ["noRouter", "rightIcon", "leftIcon", "block", "iconBlock", "variant", "round", "small", "colorOverride", "children", "ref"]);
3124
+ const { noRouter, rightIcon, leftIcon, block, iconBlock, variant, round, small, colorOverride, children, ref } = props, linkProps = __rest(props, ["noRouter", "rightIcon", "leftIcon", "block", "iconBlock", "variant", "round", "small", "colorOverride", "children", "ref"]);
3103
3125
  const theme = useThemeSafely();
3104
3126
  const linkStyles = generateLinkStyles(props, theme);
3105
3127
  const mainClassName = css.cx('omniLink', linkStyles, props.className);
3128
+ if (variant === 'text') {
3129
+ return React__namespace.createElement(Text, { className: mainClassName, tag: "div" }, props.children);
3130
+ }
3106
3131
  const content = React__namespace.createElement(LinkContent, Object.assign({}, props));
3107
3132
  if (props.noRouter) {
3108
3133
  return (React__namespace.createElement("a", Object.assign({}, linkProps, { target: props.target, className: mainClassName }), content));
@@ -3110,7 +3135,6 @@ const OmniLink = (props) => {
3110
3135
  return (React__namespace.createElement(reactRouterDom.Link, Object.assign({}, linkProps, { className: mainClassName, to: props.href }), content));
3111
3136
  };
3112
3137
 
3113
- //TB: test in safari with the new arrow
3114
3138
  const roundPxPadding = '4px';
3115
3139
  const Picker = (props) => {
3116
3140
  const selectProps = __rest(props
@@ -4603,10 +4627,13 @@ const enumToEntities = (enumObj) => {
4603
4627
  };
4604
4628
 
4605
4629
  const Link = (props) => {
4606
- const linkProps = __rest(props, ["rightIcon", "leftIcon", "block", "iconBlock", "variant", "round", "small", "colorOverride", "children", "ref"]);
4630
+ const { rightIcon, leftIcon, block, iconBlock, variant, round, small, colorOverride, children, ref } = props, linkProps = __rest(props, ["rightIcon", "leftIcon", "block", "iconBlock", "variant", "round", "small", "colorOverride", "children", "ref"]);
4607
4631
  const theme = useThemeSafely();
4608
4632
  const linkStyles = generateLinkStyles(props, theme);
4609
4633
  const mainClassName = css.cx('link', linkStyles, props.className);
4634
+ if (variant === 'text') {
4635
+ return React__namespace.createElement(Text, { className: mainClassName, tag: "div" }, props.children);
4636
+ }
4610
4637
  return (React__namespace.createElement("a", Object.assign({}, linkProps, { target: props.target, className: mainClassName }),
4611
4638
  React__namespace.createElement(LinkContent, Object.assign({}, props))));
4612
4639
  };
@@ -4629,11 +4656,11 @@ const ThemeRenderer = (p) => {
4629
4656
  let colorBox;
4630
4657
  if (/color/i.test(key)) {
4631
4658
  colorBox = (React__namespace.createElement("span", { className: css.css({
4632
- display: 'inline-block',
4659
+ display: 'block',
4633
4660
  border: '1px solid black',
4634
- width: 24,
4661
+ width: '100%',
4635
4662
  height: 24,
4636
- backgroundColor: value
4663
+ background: value
4637
4664
  }) }));
4638
4665
  }
4639
4666
  return (React__namespace.createElement(Tr, { key: key },
@@ -4644,7 +4671,7 @@ const ThemeRenderer = (p) => {
4644
4671
  alignItems: 'center',
4645
4672
  gap: '1rem'
4646
4673
  }) },
4647
- value,
4674
+ React__namespace.createElement("span", { className: css.css({ flexShrink: 1 }) }, value),
4648
4675
  " ",
4649
4676
  colorBox))));
4650
4677
  }))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mackin.com/styleguide",
3
- "version": "8.2.3",
3
+ "version": "8.3.0",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",