@codecademy/brand 5.8.1 → 5.9.0-alpha.10aaf123e.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/Accordion/index.d.ts +271 -0
- package/dist/Accordion/index.js +130 -0
- package/dist/AccordionAreaDeprecated/index.d.ts +20 -0
- package/dist/AccordionAreaDeprecated/index.js +60 -0
- package/dist/AccordionButtonDeprecated/ButtonDeprecated/index.d.ts +93 -0
- package/dist/AccordionButtonDeprecated/ButtonDeprecated/index.js +65 -0
- package/dist/AccordionButtonDeprecated/ButtonDeprecated/styles/index.module.scss +104 -0
- package/dist/AccordionButtonDeprecated/ButtonDeprecated/styles/mixins.scss +109 -0
- package/dist/AccordionButtonDeprecated/ButtonDeprecated/styles/variables.scss +54 -0
- package/dist/AccordionButtonDeprecated/ButtonDeprecatedBase/index.d.ts +43 -0
- package/dist/AccordionButtonDeprecated/ButtonDeprecatedBase/index.js +71 -0
- package/dist/AccordionButtonDeprecated/ButtonDeprecatedBase/styles.module.scss +74 -0
- package/dist/AccordionButtonDeprecated/index.d.ts +25 -0
- package/dist/AccordionButtonDeprecated/index.js +65 -0
- package/dist/AccordionButtonDeprecated/styles.module.scss +62 -0
- package/dist/AccordionDeprecated/index.d.ts +39 -0
- package/dist/AccordionDeprecated/index.js +39 -0
- package/dist/LayoutMenu/AccordionMenu.js +23 -49
- package/dist/LayoutMenuVariant/AccordionMenu.js +20 -60
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/stories/Molecules/Accordion.stories.js +122 -0
- package/dist/stories/Molecules/AccordionDeprecated.stories.js +19 -0
- package/dist/typings/react.d.ts +7 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/omitProps.d.ts +10 -0
- package/dist/utils/omitProps.js +18 -0
- package/package.json +5 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* eslint-disable react/destructuring-assignment */
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import hasIn from 'lodash/hasIn';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { omitProps } from '../../utils';
|
|
6
|
+
import { ButtonDeprecatedBase } from '../ButtonDeprecatedBase';
|
|
7
|
+
// eslint-disable-next-line gamut/no-css-standalone
|
|
8
|
+
import styles from './styles/index.module.scss';
|
|
9
|
+
|
|
10
|
+
// themes can be an alias to a color
|
|
11
|
+
// or a unique button type
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
export const buttonPresetThemes = {
|
|
14
|
+
secondary: 'mint',
|
|
15
|
+
platform: 'greyblue',
|
|
16
|
+
lantern: 'darkmint',
|
|
17
|
+
royalblue: 'brand-purple'
|
|
18
|
+
};
|
|
19
|
+
const themes = ['hyper', 'navy', 'red', 'white', 'brand-red', 'brand-yellow', 'brand-purple', 'brand-dark-blue', 'brand-blue', 'mint', 'darkmint', 'grey', 'greyblue'];
|
|
20
|
+
const propKeys = ['theme', 'size', 'outline', 'underline', 'link', 'caps', 'go', 'children', 'block', 'className', 'round', 'square', 'flat', 'fitText', 'onClick'];
|
|
21
|
+
const isPreset = theme => {
|
|
22
|
+
return hasIn(buttonPresetThemes, theme);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated
|
|
27
|
+
* This component is deprecated and is no longer supported.
|
|
28
|
+
*
|
|
29
|
+
* See [FillButon](https://gamut.codecademy.com/storybook/?path=/docs/atoms-button--fill-button#fill-button)
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* import { FillButton } fom '@codecademy/gamut';
|
|
33
|
+
*
|
|
34
|
+
* <FillButton variant="primary" />
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
export const ButtonDeprecated = props => {
|
|
38
|
+
let {
|
|
39
|
+
theme = 'brand-red'
|
|
40
|
+
} = props;
|
|
41
|
+
if (isPreset(theme)) {
|
|
42
|
+
theme = buttonPresetThemes[theme];
|
|
43
|
+
}
|
|
44
|
+
const typeClassName = props.link ? styles.link : styles.btn;
|
|
45
|
+
const themeClassName = props.link ? styles[`link-${theme}`] : styles[`btn-${theme}`];
|
|
46
|
+
const classes = cx(typeClassName, themeClassName, styles[props.size], {
|
|
47
|
+
[styles.block]: props.block,
|
|
48
|
+
[styles.go]: props.go,
|
|
49
|
+
[styles.outline]: props.outline,
|
|
50
|
+
[styles.underline]: props.underline,
|
|
51
|
+
[styles.caps]: props.caps,
|
|
52
|
+
[styles.round]: props.round,
|
|
53
|
+
[styles.square]: props.square,
|
|
54
|
+
[styles.flat]: props.flat,
|
|
55
|
+
[styles['fit-text']]: props.fitText
|
|
56
|
+
}, props.className);
|
|
57
|
+
const propsToTransfer = omitProps(propKeys, props);
|
|
58
|
+
return /*#__PURE__*/_jsx(ButtonDeprecatedBase, {
|
|
59
|
+
...propsToTransfer,
|
|
60
|
+
className: classes,
|
|
61
|
+
link: props.link,
|
|
62
|
+
onClick: props.onClick,
|
|
63
|
+
children: props.children
|
|
64
|
+
});
|
|
65
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
@use "sass:color";
|
|
2
|
+
@use "variables";
|
|
3
|
+
@use "mixins";
|
|
4
|
+
//
|
|
5
|
+
// Base styles
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
.btn {
|
|
9
|
+
align-items: center;
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
font-weight: variables.$btn-font-weight;
|
|
13
|
+
-webkit-font-smoothing: antialiased;
|
|
14
|
+
-moz-osx-font-smoothing: grayscale;
|
|
15
|
+
border: 1px solid transparent;
|
|
16
|
+
border-radius: variables.$btn-border-radius;
|
|
17
|
+
user-select: none;
|
|
18
|
+
@include mixins.button-size(
|
|
19
|
+
variables.$btn-padding-y,
|
|
20
|
+
variables.$btn-padding-x,
|
|
21
|
+
variables.$btn-font-size-base,
|
|
22
|
+
variables.$btn-line-height,
|
|
23
|
+
variables.$btn-min-width-sm
|
|
24
|
+
);
|
|
25
|
+
transition: all 0.1s ease-in-out;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Future-proof disabling of clicks on `<a>` elements
|
|
29
|
+
a.btn.disabled,
|
|
30
|
+
fieldset[disabled] a.btn {
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@each $name, $color in variables.$btn-swatches {
|
|
35
|
+
@if $name == "brand-yellow" {
|
|
36
|
+
@include mixins.button-variants($name, variables.$color-black, $color);
|
|
37
|
+
} @else if color.channel(color.to-space($color, hsl), "lightness") > 68 {
|
|
38
|
+
@include mixins.button-variants($name, variables.$color-black, $color);
|
|
39
|
+
} @else {
|
|
40
|
+
@include mixins.button-variants($name, variables.$color-white, $color);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.round {
|
|
45
|
+
border-radius: variables.$btn-round-border-radius;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.square {
|
|
49
|
+
border-radius: 0;
|
|
50
|
+
}
|
|
51
|
+
//
|
|
52
|
+
// Button Sizes
|
|
53
|
+
//
|
|
54
|
+
|
|
55
|
+
.large {
|
|
56
|
+
// line-height: ensure even-numbered height of button next to large input
|
|
57
|
+
@include mixins.button-size(
|
|
58
|
+
variables.$btn-padding-y-lg,
|
|
59
|
+
variables.$btn-padding-x-lg,
|
|
60
|
+
variables.$btn-font-size-lg,
|
|
61
|
+
variables.$btn-line-height-lg,
|
|
62
|
+
variables.$btn-min-width-lg
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.small {
|
|
67
|
+
// line-height: ensure proper height of button next to small input
|
|
68
|
+
@include mixins.button-size(
|
|
69
|
+
variables.$btn-padding-y-sm,
|
|
70
|
+
variables.$btn-padding-x-sm,
|
|
71
|
+
variables.$btn-font-size-sm,
|
|
72
|
+
variables.$btn-line-height-sm,
|
|
73
|
+
variables.$btn-min-width-sm
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//
|
|
78
|
+
// Block buttovariables.n
|
|
79
|
+
//
|
|
80
|
+
|
|
81
|
+
.block {
|
|
82
|
+
display: flex;
|
|
83
|
+
width: 100%;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.caps {
|
|
87
|
+
text-transform: uppercase;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.underline {
|
|
91
|
+
&:hover,
|
|
92
|
+
&:focus {
|
|
93
|
+
text-decoration: underline;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Specificity overrides
|
|
98
|
+
input[type="submit"],
|
|
99
|
+
input[type="reset"],
|
|
100
|
+
input[type="button"] {
|
|
101
|
+
&.block {
|
|
102
|
+
width: 100%;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
@use "sass:color";
|
|
2
|
+
@use "variables";
|
|
3
|
+
|
|
4
|
+
// Button variants
|
|
5
|
+
//
|
|
6
|
+
// Easily pump out default styles, as well as :hover, :focus, :active,
|
|
7
|
+
// and disabled options for all buttons
|
|
8
|
+
|
|
9
|
+
@mixin button-variant($color, $background, $border: transparent) {
|
|
10
|
+
$active-background: color.mix(variables.$color-black, $background);
|
|
11
|
+
|
|
12
|
+
@if $border == transparent {
|
|
13
|
+
$active-border: transparent;
|
|
14
|
+
$active-border-hover: transparent;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
color: $color;
|
|
18
|
+
background-color: $background;
|
|
19
|
+
border-color: $border;
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
box-shadow: 0 2px 4px variables.$btn-box-shadow-color;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&:focus-visible {
|
|
26
|
+
box-shadow: 0 0 0 2px variables.$color-white, 0 0 0 4px $background;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&:focus-visible,
|
|
30
|
+
&:hover {
|
|
31
|
+
text-decoration: none;
|
|
32
|
+
color: $color;
|
|
33
|
+
|
|
34
|
+
&:active {
|
|
35
|
+
box-shadow: 0 2px 4px variables.$btn-box-shadow-color;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&:active {
|
|
40
|
+
background-color: $active-background;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&:disabled {
|
|
44
|
+
background-color: variables.$btn-disabled-color;
|
|
45
|
+
|
|
46
|
+
&:hover {
|
|
47
|
+
box-shadow: none;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@mixin button-flat-variant($color) {
|
|
53
|
+
color: $color;
|
|
54
|
+
background-color: transparent;
|
|
55
|
+
|
|
56
|
+
&:hover,
|
|
57
|
+
&:active {
|
|
58
|
+
box-shadow: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&:focus-visible {
|
|
62
|
+
box-shadow: 0 0 0 2px variables.$color-white, 0 0 0 4px $color;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&:disabled {
|
|
66
|
+
color: variables.$btn-disabled-color;
|
|
67
|
+
background-color: transparent;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Button sizes
|
|
72
|
+
@mixin button-size(
|
|
73
|
+
$padding-y,
|
|
74
|
+
$padding-x,
|
|
75
|
+
$font-size,
|
|
76
|
+
$line-height,
|
|
77
|
+
$min-width
|
|
78
|
+
) {
|
|
79
|
+
padding: $padding-y $padding-x;
|
|
80
|
+
font-size: $font-size;
|
|
81
|
+
line-height: $line-height;
|
|
82
|
+
min-width: $min-width;
|
|
83
|
+
|
|
84
|
+
&.fit-text {
|
|
85
|
+
min-width: 0;
|
|
86
|
+
min-height: 0;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@mixin button-variants($name, $color, $background, $border: transparent) {
|
|
91
|
+
.btn-#{$name} {
|
|
92
|
+
@include button-variant($color, $background, $border);
|
|
93
|
+
&.flat {
|
|
94
|
+
@include button-flat-variant($background);
|
|
95
|
+
}
|
|
96
|
+
@content;
|
|
97
|
+
}
|
|
98
|
+
.link-#{$name} {
|
|
99
|
+
font-weight: bold;
|
|
100
|
+
-webkit-font-smoothing: antialiased;
|
|
101
|
+
-moz-osx-font-smoothing: grayscale;
|
|
102
|
+
color: $background;
|
|
103
|
+
text-decoration: underline;
|
|
104
|
+
|
|
105
|
+
&:disabled {
|
|
106
|
+
color: variables.$btn-disabled-color;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
$btn-padding-x: 1rem !default;
|
|
2
|
+
$btn-padding-y: 0.375rem !default;
|
|
3
|
+
$btn-font-weight: bold !default;
|
|
4
|
+
|
|
5
|
+
$btn-line-height: 1.5 !default;
|
|
6
|
+
$btn-line-height-lg: calc(4 / 3) !default;
|
|
7
|
+
$btn-line-height-sm: 1.5 !default;
|
|
8
|
+
|
|
9
|
+
$btn-font-size-base: 1rem !default;
|
|
10
|
+
$btn-font-size-lg: 1.25rem !default;
|
|
11
|
+
$btn-font-size-sm: 1rem !default;
|
|
12
|
+
$btn-font-size-xs: 0.75rem !default;
|
|
13
|
+
|
|
14
|
+
$btn-padding-x-sm: 0.75rem !default;
|
|
15
|
+
$btn-padding-y-sm: 0.25rem !default;
|
|
16
|
+
$btn-min-width-sm: 8rem !default;
|
|
17
|
+
|
|
18
|
+
$btn-padding-x-lg: 1.25rem !default;
|
|
19
|
+
$btn-padding-y-lg: 0.75rem !default;
|
|
20
|
+
$btn-min-width-lg: 10rem !default;
|
|
21
|
+
|
|
22
|
+
$btn-border-radius: 2px !default;
|
|
23
|
+
$btn-round-border-radius: 50px !default;
|
|
24
|
+
|
|
25
|
+
$btn-state-modifier: 20% !default;
|
|
26
|
+
$btn-color-modifier: 10% !default;
|
|
27
|
+
$btn-outline-hover-state-modifier: 0.9 !default;
|
|
28
|
+
$btn-outline-active-state-modifier: 0.6 !default;
|
|
29
|
+
$btn-box-shadow-focus-modifier: 0.5 !default;
|
|
30
|
+
|
|
31
|
+
$btn-disabled-color: #646466;
|
|
32
|
+
$btn-box-shadow-color: rgba(0, 0, 0, 0.3);
|
|
33
|
+
|
|
34
|
+
$btn-swatches: (
|
|
35
|
+
// Gamut Next
|
|
36
|
+
"hyper": #3a10e5,
|
|
37
|
+
"red": #e91c11,
|
|
38
|
+
"navy": #10162f,
|
|
39
|
+
"white": #ffffff,
|
|
40
|
+
"grey": #c4c3c7,
|
|
41
|
+
// Gamut Classic
|
|
42
|
+
"brand-blue": #3069f0,
|
|
43
|
+
"brand-red": #fd4d3f,
|
|
44
|
+
"brand-yellow": #ffd500,
|
|
45
|
+
"brand-purple": #6400e4,
|
|
46
|
+
"brand-dark-blue": #141c3a,
|
|
47
|
+
// Editor
|
|
48
|
+
"mint": #34b3a0,
|
|
49
|
+
"darkmint": #1a7b72,
|
|
50
|
+
"greyblue": #354551
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
$color-black: #000000;
|
|
54
|
+
$color-white: #ffffff;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { HTMLProps, ReactNode } from 'react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ChildComponentDescriptor } from '../../typings/react';
|
|
4
|
+
export type ButtonDeprecatedBaseProps = Omit<HTMLProps<HTMLAnchorElement> & HTMLProps<HTMLButtonElement>, 'as' | 'size'> & {
|
|
5
|
+
/**
|
|
6
|
+
* Component type to wrap children with.
|
|
7
|
+
*/
|
|
8
|
+
as?: ChildComponentDescriptor;
|
|
9
|
+
/**
|
|
10
|
+
* @remarks We would love to properly type this with generics, but cannot yet.
|
|
11
|
+
* @see https://github.com/Codecademy/gamut/pull/270#discussion_r270917147
|
|
12
|
+
* @see https://github.com/Microsoft/TypeScript/issues/21048
|
|
13
|
+
*/
|
|
14
|
+
asProps?: any;
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
className?: string;
|
|
17
|
+
href?: string;
|
|
18
|
+
target?: string;
|
|
19
|
+
rel?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Variant that displays the button as an inline link element, but maintains its semantic meaning as a button.
|
|
22
|
+
*/
|
|
23
|
+
link?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* @remarks
|
|
26
|
+
* Technically, this is only ever a button event *or* a link event.
|
|
27
|
+
* We '&' them together for ease of usage.
|
|
28
|
+
*/
|
|
29
|
+
onClick?: (event: React.MouseEvent<HTMLAnchorElement> & React.MouseEvent<HTMLButtonElement>) => void;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated
|
|
33
|
+
* This component is deprecated and is no longer supported.
|
|
34
|
+
*
|
|
35
|
+
* See [Anchor](https://gamut.codecademy.com/storybook/?path=/docs/typography-anchor--anchor) for similiar functionality
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* import { Anchor } from '@codecademy/gamut';
|
|
39
|
+
*
|
|
40
|
+
* <Anchor variant="interface">Button</Anchor>
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
export declare const ButtonDeprecatedBase: React.FC<ButtonDeprecatedBaseProps>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { omitProps } from '../../utils';
|
|
4
|
+
// eslint-disable-next-line gamut/no-css-standalone
|
|
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'];
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated
|
|
10
|
+
* This component is deprecated and is no longer supported.
|
|
11
|
+
*
|
|
12
|
+
* See [Anchor](https://gamut.codecademy.com/storybook/?path=/docs/typography-anchor--anchor) for similiar functionality
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { Anchor } from '@codecademy/gamut';
|
|
16
|
+
*
|
|
17
|
+
* <Anchor variant="interface">Button</Anchor>
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export const ButtonDeprecatedBase = props => {
|
|
22
|
+
const {
|
|
23
|
+
href,
|
|
24
|
+
className,
|
|
25
|
+
link,
|
|
26
|
+
onClick,
|
|
27
|
+
target,
|
|
28
|
+
rel
|
|
29
|
+
} = props;
|
|
30
|
+
const {
|
|
31
|
+
as: As,
|
|
32
|
+
asProps = {},
|
|
33
|
+
...restOfProps
|
|
34
|
+
} = props;
|
|
35
|
+
const propsToTransfer = omitProps(propKeys, restOfProps);
|
|
36
|
+
const classes = cx(styles.basicBtn, className, {
|
|
37
|
+
[styles.basicLink]: link
|
|
38
|
+
});
|
|
39
|
+
const defaultProps = {
|
|
40
|
+
...propsToTransfer,
|
|
41
|
+
className: classes,
|
|
42
|
+
onClick,
|
|
43
|
+
'data-btn': true
|
|
44
|
+
};
|
|
45
|
+
if (As) {
|
|
46
|
+
return /*#__PURE__*/_jsx(As, {
|
|
47
|
+
...defaultProps,
|
|
48
|
+
...asProps
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (href) {
|
|
52
|
+
// Check if this is a popup and and appropriate rel props if they don't exist (see https://web.dev/external-anchors-use-rel-noopener/)
|
|
53
|
+
const anchorProps = {
|
|
54
|
+
target,
|
|
55
|
+
rel: target === '_blank' && !rel ? 'noopener noreferrer' : rel
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Anchor tag receives children content from propsToTransfer
|
|
59
|
+
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
60
|
+
return /*#__PURE__*/_jsx("a", {
|
|
61
|
+
...defaultProps,
|
|
62
|
+
...anchorProps,
|
|
63
|
+
href: href
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// eslint-disable-next-line react/button-has-type
|
|
68
|
+
return /*#__PURE__*/_jsx("button", {
|
|
69
|
+
...defaultProps
|
|
70
|
+
});
|
|
71
|
+
};
|
|
@@ -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,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ButtonDeprecatedBaseProps } from './ButtonDeprecatedBase';
|
|
3
|
+
export type AccordionButtonSize = 'normal' | 'large';
|
|
4
|
+
export type AccordionButtonTheme = 'blue' | 'plain' | 'yellow';
|
|
5
|
+
export type AccordionButtonDeprecatedProps = ButtonDeprecatedBaseProps & {
|
|
6
|
+
/**
|
|
7
|
+
* Whether the button should display as open or closed.
|
|
8
|
+
*/
|
|
9
|
+
expanded?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Determines the size of the button.
|
|
12
|
+
*/
|
|
13
|
+
size?: 'normal' | 'large';
|
|
14
|
+
/**
|
|
15
|
+
* Visual theme for the clickable header button.
|
|
16
|
+
*/
|
|
17
|
+
theme?: 'blue' | 'plain' | 'yellow';
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated
|
|
21
|
+
* This component is in the old visual identity and will be updated soon.
|
|
22
|
+
*
|
|
23
|
+
* Check the [Gamut Board](https://www.notion.so/codecademy/Gamut-Status-Timeline-dd3c135d3848464ea6eb1b48e68fbb1d) for component status
|
|
24
|
+
*/
|
|
25
|
+
export declare const AccordionButtonDeprecated: React.FC<AccordionButtonDeprecatedProps>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ArrowChevronDownIcon } from '@codecademy/gamut-icons';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ButtonDeprecated } from './ButtonDeprecated';
|
|
5
|
+
import { ButtonDeprecatedBase } from './ButtonDeprecatedBase';
|
|
6
|
+
// eslint-disable-next-line gamut/no-css-standalone
|
|
7
|
+
import styles from './styles.module.scss';
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
const buttonThemes = {
|
|
10
|
+
blue: {
|
|
11
|
+
component: ButtonDeprecated,
|
|
12
|
+
props: {
|
|
13
|
+
flat: true,
|
|
14
|
+
theme: 'white'
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
plain: {
|
|
18
|
+
component: ButtonDeprecated,
|
|
19
|
+
props: {
|
|
20
|
+
flat: true,
|
|
21
|
+
theme: 'brand-dark-blue'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
yellow: {
|
|
25
|
+
component: ButtonDeprecatedBase,
|
|
26
|
+
props: {}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated
|
|
32
|
+
* This component is in the old visual identity and will be updated soon.
|
|
33
|
+
*
|
|
34
|
+
* Check the [Gamut Board](https://www.notion.so/codecademy/Gamut-Status-Timeline-dd3c135d3848464ea6eb1b48e68fbb1d) for component status
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
export const AccordionButtonDeprecated = ({
|
|
38
|
+
children,
|
|
39
|
+
className,
|
|
40
|
+
expanded,
|
|
41
|
+
size = 'normal',
|
|
42
|
+
theme = 'plain',
|
|
43
|
+
...baseProps
|
|
44
|
+
}) => {
|
|
45
|
+
const {
|
|
46
|
+
component: ButtonComponent,
|
|
47
|
+
props
|
|
48
|
+
} = buttonThemes[theme];
|
|
49
|
+
const iconSize = size === 'large' ? 30 : undefined;
|
|
50
|
+
return /*#__PURE__*/_jsxs(ButtonComponent, {
|
|
51
|
+
"aria-expanded": expanded,
|
|
52
|
+
className: cx(styles.accordionButton, styles[theme], styles[size], className),
|
|
53
|
+
...baseProps,
|
|
54
|
+
...props,
|
|
55
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
56
|
+
className: styles.children,
|
|
57
|
+
children: children
|
|
58
|
+
}), /*#__PURE__*/_jsx(ArrowChevronDownIcon, {
|
|
59
|
+
"aria-hidden": true,
|
|
60
|
+
className: cx(styles.expansionIcon, expanded && styles.expansionIconExpanded),
|
|
61
|
+
height: iconSize,
|
|
62
|
+
width: iconSize
|
|
63
|
+
})]
|
|
64
|
+
});
|
|
65
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// button + class beats ButtonDeprecated .btn / .basicBtn center alignment
|
|
2
|
+
// when CSS module order varies across consuming apps.
|
|
3
|
+
button.accordionButton {
|
|
4
|
+
align-items: center;
|
|
5
|
+
display: flex;
|
|
6
|
+
font-weight: bold;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
padding: 0.375rem 1rem;
|
|
9
|
+
text-align: left;
|
|
10
|
+
width: 100%;
|
|
11
|
+
|
|
12
|
+
.children {
|
|
13
|
+
font-weight: bold;
|
|
14
|
+
text-align: left;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&.blue {
|
|
18
|
+
color: #a5befa;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&.yellow {
|
|
22
|
+
background-color: #fff2b3;
|
|
23
|
+
border: solid #ffe359;
|
|
24
|
+
border-width: 1px 0;
|
|
25
|
+
transition: background-color 0.15s ease-in-out;
|
|
26
|
+
|
|
27
|
+
&:focus-visible {
|
|
28
|
+
border-color: #b37620;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:focus,
|
|
32
|
+
&:hover {
|
|
33
|
+
background-color: #ffec8c;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&.large {
|
|
38
|
+
border-radius: 2px;
|
|
39
|
+
font-size: 1.5rem;
|
|
40
|
+
|
|
41
|
+
.children {
|
|
42
|
+
padding-top: 0.2rem;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.expansionIcon {
|
|
46
|
+
margin-left: 1rem;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@media only screen and (min-width: 64rem) {
|
|
50
|
+
font-size: 1.75rem;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.expansionIcon {
|
|
56
|
+
margin-left: 0.75rem;
|
|
57
|
+
transition: transform 0.35s ease-out;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.expansionIconExpanded {
|
|
61
|
+
transform: rotate(-180deg);
|
|
62
|
+
}
|