@codecademy/brand 5.9.0-alpha.c7d5bcc33.0 → 5.9.0-alpha.f072baf5b.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 (43) hide show
  1. package/dist/AccordionAreaDeprecated/index.d.ts +20 -0
  2. package/dist/AccordionAreaDeprecated/index.js +60 -0
  3. package/dist/AccordionButtonDeprecated/ButtonDeprecated/index.d.ts +93 -0
  4. package/dist/AccordionButtonDeprecated/ButtonDeprecated/index.js +65 -0
  5. package/dist/AccordionButtonDeprecated/ButtonDeprecated/styles/index.module.scss +104 -0
  6. package/dist/{AccordionDeprecated/AccordionButtonDeprecated → AccordionButtonDeprecated}/ButtonDeprecated/styles/mixins.scss +20 -4
  7. package/dist/AccordionButtonDeprecated/ButtonDeprecated/styles/variables.scss +54 -0
  8. package/dist/AccordionButtonDeprecated/ButtonDeprecatedBase/index.d.ts +43 -0
  9. package/dist/AccordionButtonDeprecated/ButtonDeprecatedBase/index.js +71 -0
  10. package/dist/AccordionButtonDeprecated/index.d.ts +25 -0
  11. package/dist/{AccordionDeprecated/AccordionButtonDeprecated → AccordionButtonDeprecated}/index.js +23 -8
  12. package/dist/AccordionButtonDeprecated/styles.module.scss +61 -0
  13. package/dist/AccordionDeprecated/index.d.ts +28 -7
  14. package/dist/AccordionDeprecated/index.js +16 -11
  15. package/dist/AppHeader/AppHeaderElements/AppHeaderLink/index.d.ts +4 -4
  16. package/dist/AppHeader/AppHeaderElements/AppHeaderLinkSections/elements.d.ts +4 -4
  17. package/dist/AppHeader/AppHeaderElements/AppHeaderSection/elements.d.ts +2 -2
  18. package/dist/AppHeader/shared/elements.d.ts +2 -2
  19. package/dist/Carousel/elements.d.ts +2 -2
  20. package/dist/DropdownButton/index.d.ts +2 -2
  21. package/dist/LayoutMenu/AccordionMenu.js +3 -3
  22. package/dist/LayoutMenuVariant/AccordionMenu.js +4 -4
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.js +2 -0
  25. package/dist/stories/Molecules/AccordionDeprecated.stories.js +19 -0
  26. package/dist/typings/react.d.ts +7 -0
  27. package/dist/utils/index.d.ts +1 -0
  28. package/dist/utils/index.js +1 -0
  29. package/dist/utils/omitProps.d.ts +10 -0
  30. package/dist/utils/omitProps.js +18 -0
  31. package/package.json +5 -1
  32. package/dist/AccordionDeprecated/AccordionAreaDeprecated/index.d.ts +0 -12
  33. package/dist/AccordionDeprecated/AccordionAreaDeprecated/index.js +0 -55
  34. package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecated/index.d.ts +0 -9
  35. package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecated/index.js +0 -24
  36. package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecated/styles/index.module.scss +0 -30
  37. package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecated/styles/variables.scss +0 -16
  38. package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecatedBase/index.d.ts +0 -5
  39. package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecatedBase/index.js +0 -22
  40. package/dist/AccordionDeprecated/AccordionButtonDeprecated/index.d.ts +0 -15
  41. package/dist/AccordionDeprecated/AccordionButtonDeprecated/styles.module.scss +0 -22
  42. package/dist/styles/gamut-styles-utils/index.scss +0 -28
  43. /package/dist/{AccordionDeprecated/AccordionButtonDeprecated → AccordionButtonDeprecated}/ButtonDeprecatedBase/styles.module.scss +0 -0
@@ -0,0 +1 @@
1
+ export * from './omitProps';
@@ -0,0 +1,10 @@
1
+ export type RemoveFrom<TContainer, TRemoved> = {
2
+ [P in keyof TContainer]: P extends keyof TRemoved ? never : TContainer[P];
3
+ };
4
+ /**
5
+ * omitProps
6
+ *
7
+ * removes a provided array of props from a props object,
8
+ * leaving necessary props like children intact
9
+ */
10
+ export declare function omitProps<TOmittedProps extends {}, TProps extends {}>(initialPropsToOmit: TOmittedProps | (keyof TOmittedProps)[], props: TProps): RemoveFrom<TOmittedProps, TProps>;
@@ -0,0 +1,18 @@
1
+ import invariant from 'invariant';
2
+ import isPlainObject from 'lodash/isPlainObject';
3
+ import omit from 'lodash/omit';
4
+ import without from 'lodash/without';
5
+ /**
6
+ * omitProps
7
+ *
8
+ * removes a provided array of props from a props object,
9
+ * leaving necessary props like children intact
10
+ */
11
+ export function omitProps(initialPropsToOmit, props) {
12
+ const propsToOmit = isPlainObject(initialPropsToOmit) ? Object.keys(initialPropsToOmit) : initialPropsToOmit;
13
+ invariant(Array.isArray(propsToOmit), 'omitProps first argument should be an Array');
14
+
15
+ // allow all data-* props, mainly used for testing libraries
16
+ const dataProps = propsToOmit.filter(p => /^data-.*/.exec(p));
17
+ return omit(props, without(propsToOmit, 'children', 'className', ...dataProps));
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codecademy/brand",
3
- "version": "5.9.0-alpha.c7d5bcc33.0",
3
+ "version": "5.9.0-alpha.f072baf5b.0",
4
4
  "description": "Brand component library for Codecademy",
5
5
  "license": "MIT",
6
6
  "repository": "git@github.com:codecademy-engineering/mono.git",
@@ -21,6 +21,7 @@
21
21
  "framer-motion": "^11.18.0",
22
22
  "freezeframe": "^5.0.2",
23
23
  "intersection-observer": "^0.12.0",
24
+ "invariant": "^2.2.4",
24
25
  "ismobilejs": "^1.1.1",
25
26
  "lodash": "^4.18.1",
26
27
  "pluralize": "^8.0.0",
@@ -28,6 +29,9 @@
28
29
  "react-use": "15.3.8",
29
30
  "universal-cookie": "^8.0.1"
30
31
  },
32
+ "devDependencies": {
33
+ "@types/invariant": "^2.2.37"
34
+ },
31
35
  "peerDependencies": {
32
36
  "@codecademy/gamut": "*",
33
37
  "@codecademy/gamut-icons": "*",
@@ -1,12 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- export type AccordionAreaDeprecatedProps = {
3
- children: ReactNode;
4
- className?: string;
5
- expanded?: boolean;
6
- top: ReactNode;
7
- };
8
- /**
9
- * @deprecated
10
- * Vendored from Gamut for consumers that still rely on the legacy accordion API.
11
- */
12
- export declare const AccordionAreaDeprecated: React.FC<AccordionAreaDeprecatedProps>;
@@ -1,55 +0,0 @@
1
- import _styled from "@emotion/styled/base";
2
- function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
3
- import { motion } from 'framer-motion';
4
- import React, { useState } from 'react';
5
- import { useIsomorphicLayoutEffect } from 'react-use';
6
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
- const transitionDuration = 0.2;
8
- const variants = {
9
- expanded: {
10
- height: 'auto'
11
- },
12
- folded: {
13
- height: '0'
14
- }
15
- };
16
- const StyledAccordionBody = /*#__PURE__*/_styled(motion.div, {
17
- target: "esa36tz0",
18
- label: "StyledAccordionBody"
19
- })(process.env.NODE_ENV === "production" ? {
20
- name: "d3v9zr",
21
- styles: "overflow:hidden"
22
- } : {
23
- name: "d3v9zr",
24
- styles: "overflow:hidden/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9BY2NvcmRpb25EZXByZWNhdGVkL0FjY29yZGlvbkFyZWFEZXByZWNhdGVkL2luZGV4LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFZOEMiLCJmaWxlIjoiLi4vLi4vLi4vc3JjL0FjY29yZGlvbkRlcHJlY2F0ZWQvQWNjb3JkaW9uQXJlYURlcHJlY2F0ZWQvaW5kZXgudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnO1xuaW1wb3J0IHsgbW90aW9uIH0gZnJvbSAnZnJhbWVyLW1vdGlvbic7XG5pbXBvcnQgUmVhY3QsIHsgUmVhY3ROb2RlLCB1c2VTdGF0Z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HNldERlbGF5RXhwYW5kZWQoZXhwYW5kZWQpLFxuICAgICAgdHJhbnNpdGlvbkR1cmF0aW9uICogMTAwMFxuICAgICk7XG5cbiAgICByZXR1cm4gKCkgPT4gY2xlYXJUaW1lb3V0KGhhbmRsZSk7XG4gIH0sIFtleHBhbmRlZF0pO1xuXG4gIHJldHVybiAoXG4gICAgPGRpdiBjbGFzc05hbWU9e2NsYXNzTmFtZX0+XG4gICAgICB7dG9wfVxuICAgICAgPFN0eWxlZEFjY29yZGlvbkJvZHlcbiAgICAgICAgYW5pbWF0ZT17ZXhwYW5kZWQgPyAnZXhwYW5kZWQnIDogJ2ZvbGRlZCd9XG4gICAgICAgIGluaXRpYWw9e2V4cGFuZGVkID8gJ2V4cGFuZGVkJyA6ICdmb2xkZWQnfVxuICAgICAgICB0cmFuc2l0aW9uPXt7IGR1cmF0aW9uOiAwLjIsIGVhc2U6ICdlYXNlSW5PdXQnIH19XG4gICAgICAgIHZhcmlhbnRzPXt2YXJpYW50c31cbiAgICAgID5cbiAgICAgICAgeyhleHBhbmRlZCB8fCBkZWxheUV4cGFuZGVkKSAmJiBjaGlsZHJlbn1cbiAgICAgIDwvU3R5bGVkQWNjb3JkaW9uQm9keT5cbiAgICA8L2Rpdj5cbiAgKTtcbn07XG4iXX0= */",
25
- toString: _EMOTION_STRINGIFIED_CSS_ERROR__
26
- });
27
- /**
28
- * @deprecated
29
- * Vendored from Gamut for consumers that still rely on the legacy accordion API.
30
- */
31
- export const AccordionAreaDeprecated = ({
32
- children,
33
- className,
34
- expanded,
35
- top
36
- }) => {
37
- const [delayExpanded, setDelayExpanded] = useState(expanded);
38
- useIsomorphicLayoutEffect(() => {
39
- const handle = setTimeout(() => setDelayExpanded(expanded), transitionDuration * 1000);
40
- return () => clearTimeout(handle);
41
- }, [expanded]);
42
- return /*#__PURE__*/_jsxs("div", {
43
- className: className,
44
- children: [top, /*#__PURE__*/_jsx(StyledAccordionBody, {
45
- animate: expanded ? 'expanded' : 'folded',
46
- initial: expanded ? 'expanded' : 'folded',
47
- transition: {
48
- duration: 0.2,
49
- ease: 'easeInOut'
50
- },
51
- variants: variants,
52
- children: (expanded || delayExpanded) && children
53
- })]
54
- });
55
- };
@@ -1,9 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { ButtonDeprecatedBaseProps } from '../ButtonDeprecatedBase';
3
- export type ButtonDeprecatedTheme = 'brand-dark-blue' | 'white';
4
- export type ButtonDeprecatedProps = ButtonDeprecatedBaseProps & {
5
- children: ReactNode;
6
- flat?: boolean;
7
- theme?: ButtonDeprecatedTheme;
8
- };
9
- export declare const ButtonDeprecated: React.FC<ButtonDeprecatedProps>;
@@ -1,24 +0,0 @@
1
- import cx from 'classnames';
2
- import React from 'react';
3
- import { ButtonDeprecatedBase } from '../ButtonDeprecatedBase';
4
- // eslint-disable-next-line gamut/no-css-standalone -- vendored Gamut legacy accordion
5
- import styles from './styles/index.module.scss';
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
- export const ButtonDeprecated = ({
8
- theme = 'brand-dark-blue',
9
- children,
10
- className,
11
- flat,
12
- onClick,
13
- ...propsToTransfer
14
- }) => {
15
- const classes = cx(styles.btn, styles[`btn-${theme}`], {
16
- [styles.flat]: flat
17
- }, className);
18
- return /*#__PURE__*/_jsx(ButtonDeprecatedBase, {
19
- ...propsToTransfer,
20
- className: classes,
21
- onClick: onClick,
22
- children: children
23
- });
24
- };
@@ -1,30 +0,0 @@
1
- @use "variables";
2
- @use "mixins";
3
- @use "../../../../styles/gamut-styles-utils" as *;
4
-
5
- .btn {
6
- align-items: center;
7
- display: inline-flex;
8
- justify-content: center;
9
- font-weight: variables.$btn-font-weight;
10
- @include font-smoothing;
11
- border: 1px solid transparent;
12
- border-radius: variables.$btn-border-radius;
13
- user-select: none;
14
- @include mixins.button-size(
15
- variables.$btn-padding-y,
16
- variables.$btn-padding-x,
17
- variables.$btn-font-size-base,
18
- variables.$btn-line-height,
19
- variables.$btn-min-width-sm
20
- );
21
- transition: all 0.1s ease-in-out;
22
- }
23
-
24
- @include mixins.button-variants(
25
- "brand-dark-blue",
26
- $color-white,
27
- $brand-dark-blue
28
- );
29
-
30
- @include mixins.button-variants("white", $color-black, $color-white);
@@ -1,16 +0,0 @@
1
- @use "../../../../styles/gamut-styles-utils" as *;
2
-
3
- $btn-padding-x: px-rem(16) !default;
4
- $btn-padding-y: 0.375rem !default;
5
- $btn-font-weight: bold !default;
6
-
7
- $btn-line-height: 1.5 !default;
8
-
9
- $btn-font-size-base: px-rem(16) !default;
10
-
11
- $btn-min-width-sm: px-rem(128) !default;
12
-
13
- $btn-border-radius: 2px !default;
14
-
15
- $btn-disabled-color: $color-gray-600;
16
- $btn-box-shadow-color: rgba(0, 0, 0, 0.3);
@@ -1,5 +0,0 @@
1
- import React, { ButtonHTMLAttributes, ReactNode } from 'react';
2
- export type ButtonDeprecatedBaseProps = ButtonHTMLAttributes<HTMLButtonElement> & {
3
- children?: ReactNode;
4
- };
5
- export declare const ButtonDeprecatedBase: React.FC<ButtonDeprecatedBaseProps>;
@@ -1,22 +0,0 @@
1
- import cx from 'classnames';
2
- import React from 'react';
3
-
4
- // eslint-disable-next-line gamut/no-css-standalone -- vendored Gamut legacy accordion
5
- import styles from './styles.module.scss';
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
- export const ButtonDeprecatedBase = ({
8
- className,
9
- onClick,
10
- children,
11
- ...propsToTransfer
12
- }) => {
13
- const classes = cx(styles.basicBtn, className);
14
- return /*#__PURE__*/_jsx("button", {
15
- ...propsToTransfer,
16
- className: classes,
17
- onClick: onClick,
18
- type: "button",
19
- "data-btn": true,
20
- children: children
21
- });
22
- };
@@ -1,15 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- export type AccordionButtonTheme = 'blue' | 'plain';
3
- export type AccordionButtonDeprecatedProps = {
4
- children: ReactNode;
5
- className?: string;
6
- disabled?: boolean;
7
- expanded?: boolean;
8
- onClick?: React.MouseEventHandler<HTMLButtonElement>;
9
- theme?: AccordionButtonTheme;
10
- };
11
- /**
12
- * @deprecated
13
- * Vendored from Gamut for consumers that still rely on the legacy accordion API.
14
- */
15
- export declare const AccordionButtonDeprecated: React.FC<AccordionButtonDeprecatedProps>;
@@ -1,22 +0,0 @@
1
- @use "../../styles/gamut-styles-utils" as *;
2
-
3
- .accordionButton {
4
- align-items: center;
5
- display: flex;
6
- justify-content: space-between;
7
- padding: 0.375rem 1rem;
8
- width: 100%;
9
-
10
- &.blue {
11
- color: $color-blue-200;
12
- }
13
- }
14
-
15
- .expansionIcon {
16
- margin-left: 0.75rem;
17
- transition: transform 0.35s ease-out;
18
- }
19
-
20
- .expansionIconExpanded {
21
- transform: rotate(-180deg);
22
- }
@@ -1,28 +0,0 @@
1
- // Vendored subset of @codecademy/gamut-styles/utils (v17.14.0).
2
- // Gamut-styles no longer publishes SCSS utils; accordion SCSS depends on these symbols.
3
-
4
- @use "sass:math";
5
-
6
- $color-white: #ffffff;
7
- $color-black: #000000;
8
- $color-blue-200: #a5befa;
9
- $color-gray-600: #646466;
10
- $brand-dark-blue: #141c3a;
11
-
12
- @function strip-units($number) {
13
- @return math.div($number, ($number * 0 + 1));
14
- }
15
-
16
- @function px-rem($px, $base-px: 16) {
17
- @return calc(strip-units($px) / strip-units($base-px)) * 1rem;
18
- }
19
-
20
- @mixin font-smoothing($value: on) {
21
- @if $value == on {
22
- -webkit-font-smoothing: antialiased;
23
- -moz-osx-font-smoothing: grayscale;
24
- } @else {
25
- -webkit-font-smoothing: subpixel-antialiased;
26
- -moz-osx-font-smoothing: auto;
27
- }
28
- }