Skip to content

Commit 84fd946

Browse files
Merge branch 'release-23.x' of https://github.com/WGU-Open-edX/paragon into removing-react-imports-9
2 parents cc6f24f + 7427044 commit 84fd946

File tree

27 files changed

+169
-301
lines changed

27 files changed

+169
-301
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
jobs:
99
tests:
1010
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
node: [20, 24]
14+
continue-on-error: ${{ matrix.node == 24 }}
1115
steps:
1216
- name: Checkout
1317
uses: actions/checkout@v4
@@ -16,13 +20,13 @@ jobs:
1620
- name: Setup Nodejs
1721
uses: actions/setup-node@v4
1822
with:
19-
node-version-file: '.nvmrc'
23+
node-version: ${{ matrix.node }}
2024
- name: Install dependencies
2125
run: npm ci
2226
- name: Check Types
2327
run: npm run type-check
2428
- name: Lint
25-
run: npm run lint
29+
run: make lint
2630
- name: Test
2731
run: npm run test
2832
- name: Verify icon changes
@@ -38,7 +42,7 @@ jobs:
3842
- name: Build
3943
run: npm run build
4044
- name: Build Docs
41-
run: npm run build-docs
45+
run: make build-docs
4246
- name: Coverage
4347
uses: codecov/codecov-action@v4
4448
with:

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,26 @@ test.npm.%: validate-no-uncommitted-package-lock-changes
3232
requirements: ## install ci requirements
3333
npm ci
3434

35+
# npm swallows errors
36+
# see https://github.com/openedx/paragon/issues/3329
37+
#
38+
# Instead of having this directly in the build-docs script
39+
# in the top-level package.json, put it here so we can have
40+
# a single source of truth and get proper error codes in CI
41+
.PHONY: build-docs
42+
build-docs:
43+
npm run build --workspace=www
44+
45+
# npm swallows errors
46+
# see https://github.com/openedx/paragon/issues/3329
47+
#
48+
# Instead of having this directly in the lint script
49+
# in the top-level package.json, put it here so we can have
50+
# a single source of truth and get proper error codes in CI
51+
.PHONY: lint
52+
lint:
53+
npm run stylelint && npm run eslint && npm run lint --workspaces --if-present
54+
3555
i18n.extract:
3656
# Pulling display strings from .jsx files into .json files...
3757
npm run-script i18n_extract

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@
2727
"sideEffects": false,
2828
"scripts": {
2929
"build": "make build",
30-
"build-docs": "npm run build --workspace=www",
30+
"build-docs": "make build-docs",
3131
"commit": "commit",
3232
"debug-test": "node --inspect-brk node_modules/.bin/jest --runInBand --coverage",
3333
"stylelint": "stylelint \"src/**/*.scss\" \"scss/**/*.scss\" \"www/src/**/*.scss\" --config .stylelintrc.json",
34-
"lint": "npm run stylelint && eslint --ext .js --ext .jsx --ext .ts --ext .tsx --ext .json . && npm run lint --workspaces --if-present",
34+
"eslint": "eslint --ext .js --ext .jsx --ext .ts --ext .tsx --ext .json .",
35+
"lint": "make lint",
3536
"lint:fix": "npm run stylelint && eslint --fix --ext .js --ext .jsx --ext .ts --ext .tsx --ext .json . && npm run lint --workspaces --if-present",
3637
"prepublishOnly": "npm run build",
3738
"semantic-release": "semantic-release",

src/ActionRow/index.jsx renamed to src/ActionRow/index.tsx

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
import React from 'react';
2-
import PropTypes from 'prop-types';
32
import classNames from 'classnames';
43

4+
interface ActionRowProps extends React.HTMLAttributes<HTMLElement> {
5+
/** Specifies the base element */
6+
as?: React.ElementType;
7+
/** Specifies the contents of the row */
8+
children: React.ReactNode;
9+
/** Specifies class name to append to the base element */
10+
className?: string;
11+
/** Specifies whether row should be displayed horizontally */
12+
isStacked?: boolean;
13+
}
14+
515
function ActionRow({
6-
as,
7-
isStacked,
16+
as = 'div',
17+
isStacked = false,
818
children,
919
...props
10-
}) {
20+
}: ActionRowProps) {
1121
return React.createElement(
1222
as,
1323
{
@@ -21,24 +31,6 @@ function ActionRow({
2131
);
2232
}
2333

24-
ActionRow.propTypes = {
25-
/** Specifies the base element */
26-
as: PropTypes.elementType,
27-
/** Specifies class name to append to the base element */
28-
className: PropTypes.string,
29-
/** Specifies the contents of the row */
30-
children: PropTypes.node,
31-
/** Specifies whether row should be displayed horizontally */
32-
isStacked: PropTypes.bool,
33-
};
34-
35-
ActionRow.defaultProps = {
36-
as: 'div',
37-
className: undefined,
38-
children: null,
39-
isStacked: false,
40-
};
41-
4234
function ActionRowSpacer() {
4335
return <span className="pgn__action-row-spacer" />;
4436
}
Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
1+
import React, { ForwardedRef } from 'react';
32
import classNames from 'classnames';
43

4+
interface AnnotationProps extends React.HTMLAttributes<HTMLSpanElement> {
5+
/** Specifies contents of the component. */
6+
children: React.ReactNode;
7+
/** Specifies class name to append to the base element. */
8+
className?: string;
9+
/** Specifies variant to use. */
10+
variant?: 'error' | 'success' | 'warning' | 'light' | 'dark';
11+
/** Specifies arrow position. */
12+
arrowPlacement?: 'top' | 'right' | 'bottom' | 'left';
13+
}
14+
515
const Annotation = React.forwardRef(({
616
className,
7-
variant,
17+
variant = 'success',
818
children,
9-
arrowPlacement,
19+
arrowPlacement = 'bottom',
1020
...props
11-
}, ref) => (
21+
} : AnnotationProps, ref : ForwardedRef<HTMLSpanElement>) => (
1222
<span
1323
className={classNames(
1424
className,
@@ -22,21 +32,4 @@ const Annotation = React.forwardRef(({
2232
</span>
2333
));
2434

25-
Annotation.defaultProps = {
26-
className: undefined,
27-
variant: 'success',
28-
arrowPlacement: 'bottom',
29-
};
30-
31-
Annotation.propTypes = {
32-
/** Specifies contents of the component. */
33-
children: PropTypes.node.isRequired,
34-
/** Specifies class name to append to the base element. */
35-
className: PropTypes.string,
36-
/** Specifies variant to use. */
37-
variant: PropTypes.oneOf(['error', 'success', 'warning', 'light', 'dark']),
38-
/** Specifies arrow position. */
39-
arrowPlacement: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
40-
};
41-
4235
export default Annotation;
Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
import React from 'react';
2-
import PropTypes from 'prop-types';
32
import classNames from 'classnames';
3+
// @ts-ignore
44
import defaultAvatar from './default-avatar.svg';
55

6+
export interface AvatarProps extends React.ImgHTMLAttributes<HTMLImageElement> {
7+
/** Alt text. Usually the user's name */
8+
alt?: string;
9+
/** Size of the avatar */
10+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | 'huge';
11+
/** Image src of the avatar image */
12+
src?: string;
13+
}
14+
615
function Avatar({
7-
alt,
8-
size,
16+
alt = '',
17+
size = 'md',
918
src,
1019
...attrs
11-
}) {
20+
}: AvatarProps) {
1221
return (
1322
<img
1423
{...attrs}
@@ -23,19 +32,4 @@ function Avatar({
2332
);
2433
}
2534

26-
Avatar.propTypes = {
27-
/** Alt text. Usually the user's name */
28-
alt: PropTypes.string,
29-
/** Size of the avatar */
30-
size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', 'xxl', 'huge']),
31-
/** Image src of the avatar image */
32-
src: PropTypes.string,
33-
};
34-
35-
Avatar.defaultProps = {
36-
alt: '',
37-
size: 'md',
38-
src: undefined,
39-
};
40-
4135
export default Avatar;
Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
1+
import React, { ForwardedRef } from 'react';
32
import classNames from 'classnames';
43
import Button from '../Button';
5-
import Avatar from '../Avatar';
4+
import Avatar, { AvatarProps } from '../Avatar';
65

76
const buttonSizesToAvatarSize = {
87
sm: 'xs',
98
md: 'sm',
109
lg: 'md',
1110
};
1211

12+
interface AvatarButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
13+
/** The button text */
14+
children?: string;
15+
/** A class name to append to the button */
16+
className?: string;
17+
/** Show the label or only the avatar */
18+
showLabel?: boolean;
19+
/** The button size */
20+
size?: 'sm' | 'md' | 'lg';
21+
/** Image src of the avatar image */
22+
src?: string;
23+
/** The button style variant to use */
24+
variant?: string;
25+
}
26+
1327
const AvatarButton = React.forwardRef(({
1428
children,
1529
className,
16-
showLabel,
17-
size,
30+
showLabel = true,
31+
size = 'md',
1832
src,
33+
variant = 'tertiary',
1934
...attrs
20-
}, ref) => {
35+
}: AvatarButtonProps, ref: ForwardedRef<HTMLButtonElement>) => {
2136
const avatarSize = buttonSizesToAvatarSize[size] || 'sm';
2237
return (
2338
<Button
@@ -31,35 +46,12 @@ const AvatarButton = React.forwardRef(({
3146
)}
3247
size={size}
3348
ref={ref}
49+
variant={variant}
3450
>
35-
<Avatar src={src} alt={showLabel ? '' : children} size={avatarSize} />
51+
<Avatar src={src} alt={showLabel ? '' : children} size={avatarSize as AvatarProps['size']} />
3652
{showLabel && children}
3753
</Button>
3854
);
3955
});
4056

41-
AvatarButton.propTypes = {
42-
/** The button text */
43-
children: PropTypes.string,
44-
/** A class name to append to the button */
45-
className: PropTypes.string,
46-
/** Show the label or only the avatar */
47-
showLabel: PropTypes.bool,
48-
/** The button size */
49-
size: PropTypes.oneOf(['sm', 'md', 'lg']),
50-
/** Image src of the avatar image */
51-
src: PropTypes.string,
52-
/** The button style variant to use */
53-
variant: PropTypes.string,
54-
};
55-
56-
AvatarButton.defaultProps = {
57-
children: undefined,
58-
className: undefined,
59-
showLabel: true,
60-
size: 'md',
61-
src: undefined,
62-
variant: 'tertiary',
63-
};
64-
6557
export default AvatarButton;
File renamed without changes.

0 commit comments

Comments
 (0)