@codecademy/brand 5.1.0-alpha.0b3d95991.0 → 5.1.0-alpha.65779fe09.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/AccordionDeprecated/AccordionAreaDeprecated/index.d.ts +12 -0
- package/dist/AccordionDeprecated/AccordionAreaDeprecated/index.js +55 -0
- package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecated/index.d.ts +25 -0
- package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecated/index.js +32 -0
- package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecated/styles/index.module.scss +30 -0
- package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecated/styles/mixins.scss +93 -0
- package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecated/styles/variables.scss +16 -0
- package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecatedBase/index.d.ts +13 -0
- package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecatedBase/index.js +57 -0
- package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecatedBase/styles.module.scss +74 -0
- package/dist/AccordionDeprecated/AccordionButtonDeprecated/index.d.ts +13 -0
- package/dist/AccordionDeprecated/AccordionButtonDeprecated/index.js +50 -0
- package/dist/AccordionDeprecated/AccordionButtonDeprecated/styles.module.scss +22 -0
- package/dist/AccordionDeprecated/index.d.ts +18 -0
- package/dist/AccordionDeprecated/index.js +34 -0
- package/dist/AccordionDeprecated/utils/omitProps.d.ts +5 -0
- package/dist/AccordionDeprecated/utils/omitProps.js +12 -0
- package/dist/AppHeader/AppHeaderElements/AppHeaderLink/index.d.ts +5 -5
- package/dist/AppHeader/AppHeaderElements/AppHeaderLinkSections/elements.d.ts +5 -5
- package/dist/AppHeader/AppHeaderElements/AppHeaderListItem/index.d.ts +1 -1
- package/dist/AppHeader/AppHeaderElements/AppHeaderSection/elements.d.ts +10 -10
- package/dist/AppHeader/shared/elements.d.ts +9 -9
- package/dist/Carousel/elements.d.ts +2 -2
- package/dist/DropdownButton/index.d.ts +2 -2
- package/dist/GlobalFooter/FooterHeading.d.ts +2 -2
- package/dist/GlobalFooter/FooterLinks.d.ts +1 -1
- package/dist/GlobalFooter/FooterSubHeading.d.ts +2 -2
- package/dist/LayoutMenu/AccordionMenu.js +4 -3
- package/dist/LayoutMenuVariant/AccordionMenu.js +5 -4
- package/dist/LearningOutcomeBadges/LearningOutcomeLowAssessmentBadge.d.ts +1 -1
- package/dist/LearningOutcomeTile/Tile.d.ts +1 -1
- package/dist/Logos/ProLabel/ProLabelCutout/index.js +3 -3
- package/dist/Logos/ProLabel/ProLabelCutoutTransparent/index.js +2 -2
- package/dist/Logos/ProLabel/index.d.ts +3 -3
- package/dist/Logos/ProLabel/index.js +4 -5
- package/dist/Notifications/elements.d.ts +2 -2
- package/dist/ProLogoAlt/index.d.ts +3 -3
- package/dist/ProLogoAlt/index.js +4 -5
- package/dist/Testimonial/index.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
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>;
|
|
@@ -0,0 +1,55 @@
|
|
|
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9BY2NvcmRpb25EZXByZWNhdGVkL0FjY29yZGlvbkFyZWFEZXByZWNhdGVkL2luZGV4LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFZOEMiLCJmaWxlIjoiLi4vLi4vLi4vc3JjL0FjY29yZGlvbkRlcHJlY2F0ZWQvQWNjb3JkaW9uQXJlYURlcHJlY2F0ZWQvaW5kZXgudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnO1xuaW1wb3J0IHsgbW90aW9uIH0gZnJvbSAnZnJhbWVyLW1vdGlvbic7XG5pbXBvcnQgUmVhY3QsIHsgUmVhY3ROb2RlLCB1c2VTdGF0ZSB9IGZyb20gJ3JlYWN0JztcbmltcG9ydCB7IHVzZUlzb21vcnBoaWNMYXlvdXRFZmZlY3QgfSBmcm9tICdyZWFjdC11c2UnO1xuXG5jb25zdCB0cmFuc2l0aW9uRHVyYXRpb24gPSAwLjI7XG5cbmNvbnN0IHZhcmlhbnRzID0ge1xuICBleHBhbmRlZDogeyBoZWlnaHQ6ICdhdXRvJyB9LFxuICBmb2xkZWQ6IHsgaGVpZ2h0OiAnMCcgfSxcbn07XG5cbmNvbnN0IFN0eWxlZEFjY29yZGlvbkJvZHkgPSBzdHlsZWQobW90aW9uLmRpdilgXG4gIG92ZXJmbG93OiBoaWRkZW47XG5gO1xuXG5leHBvcnQgdHlwZSBBY2NvcmRpb25BcmVhRGVwcmVjYXRlZFByb3BzID0ge1xuICBjaGlsZHJlbjogUmVhY3ROb2RlO1xuICBjbGFzc05hbWU/OiBzdHJpbmc7XG4gIGV4cGFuZGVkPzogYm9vbGVhbjtcbiAgdG9wOiBSZWFjdE5vZGU7XG59O1xuXG4vKipcbiAqIEBkZXByZWNhdGVkXG4gKiBWZW5kb3JlZCBmcm9tIEdhbXV0IGZvciBjb25zdW1lcnMgdGhhdCBzdGlsbCByZWx5IG9uIHRoZSBsZWdhY3kgYWNjb3JkaW9uIEFQSS5cbiAqL1xuZXhwb3J0IGNvbnN0IEFjY29yZGlvbkFyZWFEZXByZWNhdGVkOiBSZWFjdC5GQzxcbiAgQWNjb3JkaW9uQXJlYURlcHJlY2F0ZWRQcm9wc1xuPiA9ICh7IGNoaWxkcmVuLCBjbGFzc05hbWUsIGV4cGFuZGVkLCB0b3AgfSkgPT4ge1xuICBjb25zdCBbZGVsYXlFeHBhbmRlZCwgc2V0RGVsYXlFeHBhbmRlZF0gPSB1c2VTdGF0ZShleHBhbmRlZCk7XG5cbiAgdXNlSXNvbW9ycGhpY0xheW91dEVmZmVjdCgoKSA9PiB7XG4gICAgY29uc3QgaGFuZGxlID0gc2V0VGltZW91dChcbiAgICAgICgpID0+IHNldERlbGF5RXhwYW5kZWQoZXhwYW5kZWQpLFxuICAgICAgdHJhbnNpdGlvbkR1cmF0aW9uICogMTAwMFxuICAgICk7XG5cbiAgICByZXR1cm4gKCkgPT4gY2xlYXJUaW1lb3V0KGhhbmRsZSk7XG4gIH0sIFtleHBhbmRlZF0pO1xuXG4gIHJldHVybiAoXG4gICAgPGRpdiBjbGFzc05hbWU9e2NsYXNzTmFtZX0+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
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
block?: boolean;
|
|
6
|
+
caps?: boolean;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
flat?: boolean;
|
|
10
|
+
go?: boolean;
|
|
11
|
+
href?: string;
|
|
12
|
+
rel?: string;
|
|
13
|
+
target?: string;
|
|
14
|
+
id?: string;
|
|
15
|
+
link?: boolean;
|
|
16
|
+
outline?: boolean;
|
|
17
|
+
round?: boolean;
|
|
18
|
+
size?: 'small' | 'large';
|
|
19
|
+
square?: boolean;
|
|
20
|
+
theme?: ButtonDeprecatedTheme;
|
|
21
|
+
type?: string;
|
|
22
|
+
underline?: boolean;
|
|
23
|
+
fitText?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare const ButtonDeprecated: React.FC<ButtonDeprecatedProps>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { omitProps } from '../../utils/omitProps';
|
|
4
|
+
import { ButtonDeprecatedBase } from '../ButtonDeprecatedBase';
|
|
5
|
+
// eslint-disable-next-line gamut/no-css-standalone -- vendored Gamut legacy accordion
|
|
6
|
+
import styles from './styles/index.module.scss';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
const propKeys = ['theme', 'size', 'outline', 'underline', 'link', 'caps', 'go', 'children', 'block', 'className', 'round', 'square', 'flat', 'fitText', 'onClick'];
|
|
9
|
+
export const ButtonDeprecated = props => {
|
|
10
|
+
const theme = props.theme ?? 'brand-dark-blue';
|
|
11
|
+
const typeClassName = props.link ? styles.link : styles.btn;
|
|
12
|
+
const themeClassName = props.link ? styles[`link-${theme}`] : styles[`btn-${theme}`];
|
|
13
|
+
const classes = cx(typeClassName, themeClassName, styles[props.size], {
|
|
14
|
+
[styles.block]: props.block,
|
|
15
|
+
[styles.go]: props.go,
|
|
16
|
+
[styles.outline]: props.outline,
|
|
17
|
+
[styles.underline]: props.underline,
|
|
18
|
+
[styles.caps]: props.caps,
|
|
19
|
+
[styles.round]: props.round,
|
|
20
|
+
[styles.square]: props.square,
|
|
21
|
+
[styles.flat]: props.flat,
|
|
22
|
+
[styles['fit-text']]: props.fitText
|
|
23
|
+
}, props.className);
|
|
24
|
+
const propsToTransfer = omitProps(propKeys, props);
|
|
25
|
+
return /*#__PURE__*/_jsx(ButtonDeprecatedBase, {
|
|
26
|
+
...propsToTransfer,
|
|
27
|
+
className: classes,
|
|
28
|
+
link: props.link,
|
|
29
|
+
onClick: props.onClick,
|
|
30
|
+
children: props.children
|
|
31
|
+
});
|
|
32
|
+
};
|
package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecated/styles/index.module.scss
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
@use "variables";
|
|
2
|
+
@use "mixins";
|
|
3
|
+
@use "~@codecademy/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);
|
package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecated/styles/mixins.scss
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
@use "sass:color";
|
|
2
|
+
@use "~@codecademy/gamut-styles/utils" as *;
|
|
3
|
+
@use "variables";
|
|
4
|
+
|
|
5
|
+
@mixin button-variant($color, $background, $border: transparent) {
|
|
6
|
+
$active-background: color.mix($color-black, $background);
|
|
7
|
+
|
|
8
|
+
@if $border == transparent {
|
|
9
|
+
$active-border: transparent;
|
|
10
|
+
$active-border-hover: transparent;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
color: $color;
|
|
14
|
+
background-color: $background;
|
|
15
|
+
border-color: $border;
|
|
16
|
+
|
|
17
|
+
&:hover {
|
|
18
|
+
box-shadow: 0 2px 4px variables.$btn-box-shadow-color;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&:focus-visible {
|
|
22
|
+
box-shadow: 0 0 0 2px $color-white, 0 0 0 4px $background;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&:focus-visible,
|
|
26
|
+
&:hover {
|
|
27
|
+
text-decoration: none;
|
|
28
|
+
color: $color;
|
|
29
|
+
|
|
30
|
+
&:active {
|
|
31
|
+
box-shadow: 0 2px 4px variables.$btn-box-shadow-color;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&:active {
|
|
36
|
+
background-color: $active-background;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&:disabled {
|
|
40
|
+
background-color: variables.$btn-disabled-color;
|
|
41
|
+
|
|
42
|
+
&:hover {
|
|
43
|
+
box-shadow: none;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@mixin button-flat-variant($color) {
|
|
49
|
+
color: $color;
|
|
50
|
+
background-color: transparent;
|
|
51
|
+
|
|
52
|
+
&:hover,
|
|
53
|
+
&:active {
|
|
54
|
+
box-shadow: none;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&:focus-visible {
|
|
58
|
+
box-shadow: 0 0 0 2px $color-white, 0 0 0 4px $color;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&:disabled {
|
|
62
|
+
color: variables.$btn-disabled-color;
|
|
63
|
+
background-color: transparent;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@mixin button-size(
|
|
68
|
+
$padding-y,
|
|
69
|
+
$padding-x,
|
|
70
|
+
$font-size,
|
|
71
|
+
$line-height,
|
|
72
|
+
$min-width
|
|
73
|
+
) {
|
|
74
|
+
padding: $padding-y $padding-x;
|
|
75
|
+
font-size: $font-size;
|
|
76
|
+
line-height: $line-height;
|
|
77
|
+
min-width: $min-width;
|
|
78
|
+
|
|
79
|
+
&.fit-text {
|
|
80
|
+
min-width: 0;
|
|
81
|
+
min-height: 0;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@mixin button-variants($name, $color, $background, $border: transparent) {
|
|
86
|
+
.btn-#{$name} {
|
|
87
|
+
@include button-variant($color, $background, $border);
|
|
88
|
+
&.flat {
|
|
89
|
+
@include button-flat-variant($background);
|
|
90
|
+
}
|
|
91
|
+
@content;
|
|
92
|
+
}
|
|
93
|
+
}
|
package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecated/styles/variables.scss
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
@use "~@codecademy/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);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { HTMLProps, ReactNode } from 'react';
|
|
2
|
+
export type ButtonDeprecatedBaseProps = Omit<HTMLProps<HTMLAnchorElement> & HTMLProps<HTMLButtonElement>, 'as' | 'size'> & {
|
|
3
|
+
as?: React.ElementType;
|
|
4
|
+
asProps?: Record<string, unknown>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
href?: string;
|
|
8
|
+
target?: string;
|
|
9
|
+
rel?: string;
|
|
10
|
+
link?: boolean;
|
|
11
|
+
onClick?: (event: React.MouseEvent<HTMLAnchorElement> & React.MouseEvent<HTMLButtonElement>) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const ButtonDeprecatedBase: React.FC<ButtonDeprecatedBaseProps>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { omitProps } from '../../utils/omitProps';
|
|
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
|
+
const propKeys = ['children', 'className', 'href', 'link', 'onClick', 'target', 'rel', 'as', 'asProps'];
|
|
8
|
+
export const ButtonDeprecatedBase = props => {
|
|
9
|
+
const {
|
|
10
|
+
href,
|
|
11
|
+
className,
|
|
12
|
+
link,
|
|
13
|
+
onClick,
|
|
14
|
+
target,
|
|
15
|
+
rel,
|
|
16
|
+
as: As,
|
|
17
|
+
asProps = {}
|
|
18
|
+
} = props;
|
|
19
|
+
const propsToTransfer = omitProps(propKeys, props);
|
|
20
|
+
const classes = cx(styles.basicBtn, className, {
|
|
21
|
+
[styles.basicLink]: link
|
|
22
|
+
});
|
|
23
|
+
const defaultProps = {
|
|
24
|
+
...propsToTransfer,
|
|
25
|
+
className: classes,
|
|
26
|
+
onClick,
|
|
27
|
+
'data-btn': true
|
|
28
|
+
};
|
|
29
|
+
if (As) {
|
|
30
|
+
return /*#__PURE__*/_jsx(As, {
|
|
31
|
+
...defaultProps,
|
|
32
|
+
...asProps
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (href) {
|
|
36
|
+
const anchorProps = {
|
|
37
|
+
target,
|
|
38
|
+
rel: target === '_blank' && !rel ? 'noopener noreferrer' : rel
|
|
39
|
+
};
|
|
40
|
+
return (
|
|
41
|
+
/*#__PURE__*/
|
|
42
|
+
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
43
|
+
_jsx("a", {
|
|
44
|
+
...defaultProps,
|
|
45
|
+
...anchorProps,
|
|
46
|
+
href: href
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return (
|
|
51
|
+
/*#__PURE__*/
|
|
52
|
+
// eslint-disable-next-line react/button-has-type
|
|
53
|
+
_jsx("button", {
|
|
54
|
+
...defaultProps
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
};
|
package/dist/AccordionDeprecated/AccordionButtonDeprecated/ButtonDeprecatedBase/styles.module.scss
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
.basicBtn {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
text-align: center;
|
|
4
|
+
text-decoration: none;
|
|
5
|
+
white-space: nowrap;
|
|
6
|
+
vertical-align: middle;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
font-family: inherit;
|
|
9
|
+
font: inherit;
|
|
10
|
+
padding: 0;
|
|
11
|
+
margin: 0;
|
|
12
|
+
border: none;
|
|
13
|
+
background: none;
|
|
14
|
+
color: inherit;
|
|
15
|
+
line-height: normal;
|
|
16
|
+
|
|
17
|
+
&,
|
|
18
|
+
&:active {
|
|
19
|
+
&:focus {
|
|
20
|
+
outline: none;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&:hover:focus {
|
|
25
|
+
text-decoration: none;
|
|
26
|
+
}
|
|
27
|
+
&:focus {
|
|
28
|
+
text-decoration: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:active {
|
|
32
|
+
background-image: none;
|
|
33
|
+
outline: 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&:disabled {
|
|
37
|
+
cursor: not-allowed;
|
|
38
|
+
opacity: 0.65;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.basicLink {
|
|
43
|
+
text-decoration: none;
|
|
44
|
+
vertical-align: baseline;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
|
|
47
|
+
&,
|
|
48
|
+
&:active,
|
|
49
|
+
&:disabled {
|
|
50
|
+
background-color: transparent;
|
|
51
|
+
}
|
|
52
|
+
&,
|
|
53
|
+
&:focus,
|
|
54
|
+
&:active {
|
|
55
|
+
border-color: transparent;
|
|
56
|
+
}
|
|
57
|
+
&:hover,
|
|
58
|
+
&:focus {
|
|
59
|
+
opacity: 0.7;
|
|
60
|
+
text-decoration: none;
|
|
61
|
+
border-color: transparent;
|
|
62
|
+
background-color: transparent;
|
|
63
|
+
}
|
|
64
|
+
&:hover:focus {
|
|
65
|
+
opacity: 0.7;
|
|
66
|
+
background-color: transparent;
|
|
67
|
+
}
|
|
68
|
+
&:disabled {
|
|
69
|
+
&:hover:focus {
|
|
70
|
+
opacity: 0.7;
|
|
71
|
+
text-decoration: none;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ButtonDeprecatedProps } from './ButtonDeprecated';
|
|
3
|
+
export type AccordionButtonTheme = 'blue' | 'plain';
|
|
4
|
+
export type AccordionButtonDeprecatedProps = Omit<ButtonDeprecatedProps, 'children' | 'flat' | 'theme'> & {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
expanded?: boolean;
|
|
7
|
+
theme?: AccordionButtonTheme;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated
|
|
11
|
+
* Vendored from Gamut for consumers that still rely on the legacy accordion API.
|
|
12
|
+
*/
|
|
13
|
+
export declare const AccordionButtonDeprecated: React.FC<AccordionButtonDeprecatedProps>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ArrowChevronDownIcon } from '@codecademy/gamut-icons';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { ButtonDeprecated } from './ButtonDeprecated';
|
|
5
|
+
// eslint-disable-next-line gamut/no-css-standalone -- vendored Gamut legacy accordion
|
|
6
|
+
import styles from './styles.module.scss';
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
const buttonThemes = {
|
|
9
|
+
blue: {
|
|
10
|
+
props: {
|
|
11
|
+
flat: true,
|
|
12
|
+
theme: 'white'
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
plain: {
|
|
16
|
+
props: {
|
|
17
|
+
flat: true,
|
|
18
|
+
theme: 'brand-dark-blue'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated
|
|
25
|
+
* Vendored from Gamut for consumers that still rely on the legacy accordion API.
|
|
26
|
+
*/
|
|
27
|
+
export const AccordionButtonDeprecated = ({
|
|
28
|
+
children,
|
|
29
|
+
className,
|
|
30
|
+
expanded,
|
|
31
|
+
theme = 'plain',
|
|
32
|
+
...baseProps
|
|
33
|
+
}) => {
|
|
34
|
+
const {
|
|
35
|
+
props: buttonProps
|
|
36
|
+
} = buttonThemes[theme];
|
|
37
|
+
return /*#__PURE__*/_jsxs(ButtonDeprecated, {
|
|
38
|
+
"aria-expanded": expanded,
|
|
39
|
+
className: cx(styles.accordionButton, styles[theme], className),
|
|
40
|
+
...baseProps,
|
|
41
|
+
...buttonProps,
|
|
42
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
43
|
+
className: styles.children,
|
|
44
|
+
children: children
|
|
45
|
+
}), /*#__PURE__*/_jsx(ArrowChevronDownIcon, {
|
|
46
|
+
"aria-hidden": true,
|
|
47
|
+
className: cx(styles.expansionIcon, expanded && styles.expansionIconExpanded)
|
|
48
|
+
})]
|
|
49
|
+
});
|
|
50
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
@use "~@codecademy/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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
export type ChildrenOrExpandedRender = ReactNode | ((expanded: boolean) => ReactNode);
|
|
3
|
+
export type AccordionDeprecatedProps = {
|
|
4
|
+
children: ChildrenOrExpandedRender;
|
|
5
|
+
className?: string;
|
|
6
|
+
initiallyExpanded?: boolean;
|
|
7
|
+
onClick?: (expanding: boolean) => void;
|
|
8
|
+
top: ChildrenOrExpandedRender;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated
|
|
12
|
+
* Vendored from Gamut for consumers that still rely on the legacy accordion API.
|
|
13
|
+
*/
|
|
14
|
+
export declare const AccordionDeprecated: React.FC<AccordionDeprecatedProps>;
|
|
15
|
+
export { AccordionAreaDeprecated } from './AccordionAreaDeprecated';
|
|
16
|
+
export type { AccordionAreaDeprecatedProps } from './AccordionAreaDeprecated';
|
|
17
|
+
export { AccordionButtonDeprecated } from './AccordionButtonDeprecated';
|
|
18
|
+
export type { AccordionButtonDeprecatedProps, AccordionButtonTheme, } from './AccordionButtonDeprecated';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { AccordionAreaDeprecated } from './AccordionAreaDeprecated';
|
|
3
|
+
import { AccordionButtonDeprecated } from './AccordionButtonDeprecated';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
const expandRenderer = (renderer, expanded) => renderer instanceof Function ? renderer(expanded) : renderer;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated
|
|
9
|
+
* Vendored from Gamut for consumers that still rely on the legacy accordion API.
|
|
10
|
+
*/
|
|
11
|
+
export const AccordionDeprecated = ({
|
|
12
|
+
children,
|
|
13
|
+
className,
|
|
14
|
+
initiallyExpanded,
|
|
15
|
+
onClick,
|
|
16
|
+
top
|
|
17
|
+
}) => {
|
|
18
|
+
const [expanded, setExpanded] = useState(!!initiallyExpanded);
|
|
19
|
+
return /*#__PURE__*/_jsx(AccordionAreaDeprecated, {
|
|
20
|
+
className: className,
|
|
21
|
+
expanded: expanded,
|
|
22
|
+
top: /*#__PURE__*/_jsx(AccordionButtonDeprecated, {
|
|
23
|
+
expanded: expanded,
|
|
24
|
+
onClick: () => {
|
|
25
|
+
setExpanded(!expanded);
|
|
26
|
+
onClick?.(!expanded);
|
|
27
|
+
},
|
|
28
|
+
children: expandRenderer(top, expanded)
|
|
29
|
+
}),
|
|
30
|
+
children: expandRenderer(children, expanded)
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
export { AccordionAreaDeprecated } from './AccordionAreaDeprecated';
|
|
34
|
+
export { AccordionButtonDeprecated } from './AccordionButtonDeprecated';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes a provided array of props from a props object,
|
|
3
|
+
* leaving necessary props like children intact.
|
|
4
|
+
*/
|
|
5
|
+
export declare function omitProps<T extends Record<string, unknown>>(initialPropsToOmit: string[] | Record<string, unknown>, props: T): Omit<T, string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import omit from 'lodash/omit';
|
|
2
|
+
import without from 'lodash/without';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Removes a provided array of props from a props object,
|
|
6
|
+
* leaving necessary props like children intact.
|
|
7
|
+
*/
|
|
8
|
+
export function omitProps(initialPropsToOmit, props) {
|
|
9
|
+
const propsToOmit = Array.isArray(initialPropsToOmit) ? initialPropsToOmit : Object.keys(initialPropsToOmit);
|
|
10
|
+
const dataProps = propsToOmit.filter(p => /^data-.*/.exec(p));
|
|
11
|
+
return omit(props, without(propsToOmit, 'children', 'className', ...dataProps));
|
|
12
|
+
}
|