Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
cae1399
backend done, frontend progress
vivekbopaliya Feb 16, 2024
907c057
frontend done
vivekbopaliya Feb 17, 2024
3bf54c4
Merge branch 'develop' of https://github.com/vivekbopaliya/p5.js-web-…
vivekbopaliya Feb 18, 2024
c9da6cc
icons added
vivekbopaliya Feb 18, 2024
ae08e56
UI changes
vivekbopaliya May 4, 2024
02726cb
Merge branch 'develop' of https://github.com/processing/p5.js-web-edi…
vivekbopaliya May 4, 2024
70b8df1
snapshots updated
vivekbopaliya May 29, 2024
dfb7797
small bug fixed
vivekbopaliya Jun 1, 2024
0ba7467
Merge branch 'processing:develop' into feat/privatesketch
vivekbopaliya Jun 1, 2024
64bdb22
Merge branch 'feat/privatesketch' of https://github.com/vivekbopaliya…
vivekbopaliya Jun 1, 2024
89e9716
bug fixed
vivekbopaliya Jun 1, 2024
d2cbc60
fix bugs and added protected route for private sketch
vivekbopaliya Apr 20, 2025
eafb1aa
fixed bug conflict
vivekbopaliya Apr 20, 2025
edc54da
Merge branch 'develop' into feat/privatesketch
raclim May 7, 2025
9b54f58
fix redirect bug
vivekbopaliya Jun 5, 2025
da1c2c8
Merge branch 'develop' into feat/privatesketch
vivekbopaliya Jun 5, 2025
2bb37c5
Merge branch 'develop' into feat/privatesketch
raclim Jun 10, 2025
f5864b1
refactoring code for private sketch feat
vivekbopaliya Jun 24, 2025
374e971
test error fixex
vivekbopaliya Jun 24, 2025
24b3faa
fixed bug
vivekbopaliya Jul 5, 2025
65d3021
merged main
vivekbopaliya Jul 5, 2025
c2cacf7
replaced visibility checkbox with dropdown
vivekbopaliya Jul 19, 2025
ccafec4
test cases fixed
vivekbopaliya Jul 19, 2025
4c5f9c9
test cases snapsho fixed
vivekbopaliya Jul 19, 2025
de05842
test
vivekbopaliya Jul 20, 2025
6901103
test
vivekbopaliya Jul 20, 2025
673457f
lint fixes
vivekbopaliya Jul 20, 2025
5473069
Merge branch 'develop' into feat/privatesketch
vivekbopaliya Jul 20, 2025
205b238
fixed merge conflict
vivek-oppex Jul 31, 2025
f1af0a6
.prettierrc: remove hardcoded babel as parser setting to allow typesc…
clairep94 Aug 3, 2025
8a0f302
SkipLink: lint correctly to add ; to end of type definition lines
clairep94 Aug 3, 2025
1cb8f5b
RouterTab: unit test
clairep94 Aug 3, 2025
d376207
RouterTab: update to tsx --no-verify
clairep94 Aug 3, 2025
29e1e6d
RouterTab: add typescript & install @types/react-router-dom
clairep94 Aug 3, 2025
1efe93d
Button: update to tsx --no-verify
clairep94 Aug 3, 2025
6042638
Button.tsx: migrate to typescript, add unit test, add @types/styled-c…
clairep94 Aug 3, 2025
c1883c5
ButtonOrLink: update to tsx files --no-verify
clairep94 Aug 3, 2025
eb69138
ButtonOrLink: update to typescript
clairep94 Aug 3, 2025
5dd03d1
IconButton: update to tsx --no-verify
clairep94 Aug 3, 2025
197fd67
IconButton: migrate to typescript & add unit test
clairep94 Aug 3, 2025
cfb4b82
usePrevious: update to ts --no-verify
clairep94 Aug 3, 2025
d80961c
usePrevious: migrate to typescript & add unit test
clairep94 Aug 3, 2025
24368cc
isMac: migrate to typescript and add test
clairep94 Aug 3, 2025
e67e015
useKeyDownHandlers: update to ts --no-verify
clairep94 Aug 3, 2025
1b5373c
useKeyDownHandler: migrate to typescript and add unit test
clairep94 Aug 3, 2025
b5eea95
useModalClose: update to ts --no-verify
clairep94 Aug 3, 2025
7ca1e6d
useModalClose: update to typescript & add test
clairep94 Aug 3, 2025
7075ffb
useSyncFormTranslation: update to ts --no-verify
clairep94 Aug 3, 2025
6bc9369
useSyncFormTranslations: update to typescript and add unit test
clairep94 Aug 3, 2025
94ea59a
rename test utility rerender to mountComponent
clairep94 Aug 3, 2025
a19ae27
Merge branch 'develop' into feat/privatesketch
raclim Aug 9, 2025
7618f85
Merge pull request #3034 from vivekbopaliya/feat/privatesketch
raclim Aug 9, 2025
c768735
needded
vivekbopaliya Aug 10, 2025
f405d6e
Changed scss for visibility dropdown
vivekbopaliya Aug 10, 2025
f27efc8
Msd
vivekbopaliya Aug 10, 2025
76d3e27
Merge branch 'develop' into feature-develop
raclim Aug 14, 2025
f687b6e
Merge branch 'develop' into feat/privatesketch
raclim Aug 14, 2025
c3e160e
Merge pull request #3587 from vivekbopaliya/feat/privatesketch
raclim Aug 14, 2025
6cd666a
Merge pull request #3588 from processing/feat/privatesketch
raclim Aug 14, 2025
1b72ea4
Merge branch 'develop' into pr05/migrate_client_common_rebuild
clairep94 Aug 14, 2025
be8d50a
update toolbar arrangement and styling
raclim Aug 15, 2025
d76a0f9
update styling for version picker to match toolbar
raclim Aug 15, 2025
bb2980c
let svg be styled by css
raclim Aug 15, 2025
6c92cbe
Merge branch 'develop' into feature-develop
raclim Aug 15, 2025
7ce4f54
.eslintrc: update to fix no-shadow eslint error on enums
clairep94 Aug 15, 2025
7188c1b
usePrevious: make type unknown to make more generic
clairep94 Aug 15, 2025
bee3211
RouterTab: update TabProps to interface
clairep94 Aug 15, 2025
6148c33
ButtonOrLink: update to interface
clairep94 Aug 16, 2025
3e8faea
IconButton: remove null
clairep94 Aug 16, 2025
4bd9443
Button: WIP update
clairep94 Aug 18, 2025
7718e02
SkipLink: update type to interface
clairep94 Aug 19, 2025
3428dac
.eslintrc: cherry-pick ts overrids from utils pr
clairep94 Aug 14, 2025
1a7cfaa
useSyncFormTranslations: update to be named export
clairep94 Aug 19, 2025
3676534
eslintrc: fix double config
clairep94 Aug 19, 2025
366aa7e
usePrevious: update to be named export
clairep94 Aug 19, 2025
2d8fe06
useModalClose: update to named export
clairep94 Aug 19, 2025
b1788d5
useKeyDownHandler: update to named export
clairep94 Aug 19, 2025
bc82be5
RouterTab: update to named export
clairep94 Aug 19, 2025
7b67549
ButtonOrLink: update to named export
clairep94 Aug 20, 2025
379e563
IconButton: update to interface and named export
clairep94 Aug 20, 2025
e53995c
Merge pull request #3597 from processing/feature-develop
raclim Aug 21, 2025
42d761f
Update p5Versions.js to include 1.11.10
ksen0 Aug 23, 2025
1f95dc6
adjust toolbar spacing
raclim Aug 24, 2025
6f0158e
remove extra folder
raclim Aug 24, 2025
e75e749
Merge branch 'develop' into ksen0-patch-2
raclim Aug 24, 2025
9ba39a5
Merge pull request #3600 from processing/ksen0-patch-2
raclim Aug 24, 2025
9b0a11a
2.18.0
raclim Aug 24, 2025
b201533
Merge branch 'release-2.18.0' into release
raclim Aug 24, 2025
c486593
Merge branch 'release-2.18.0' into develop
raclim Aug 24, 2025
34123d5
Merge branch 'release' into develop
raclim Aug 24, 2025
9515291
Button: update to named export
clairep94 Aug 25, 2025
dc7665d
Button: clean up type definition to interface and add basic html elem…
clairep94 Aug 25, 2025
0ff9ac1
lint
clairep94 Aug 25, 2025
a09c8d2
Merge branch 'develop' into pr05/migrate_client_common_rebuild
clairep94 Aug 25, 2025
7e7c1ab
merge with main
clairep94 Aug 25, 2025
67425a1
Button: update jsdoc
clairep94 Aug 19, 2025
001c9e4
SkipLink: Update to named export
clairep94 Aug 19, 2025
b93ac45
wip resolve @ alias -- doesn't work on npm start but works on test, a…
clairep94 Aug 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"tsx": "never"
}
],
"import/prefer-default-export": "off",
"react/jsx-filename-extension": [1, { "extensions": [".jsx", ".tsx"] }],
"comma-dangle": 0, // not sure why airbnb turned this on. gross!
"default-param-last": 0,
Expand Down Expand Up @@ -131,7 +132,13 @@
"rules": {
"no-use-before-define": "off",
"import/no-extraneous-dependencies": "off",
"no-unused-vars": "off"
"no-unused-vars": "off",
"import/no-default-export": "warn",
"no-underscore-dangle": "warn",
"react/require-default-props": "off",
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error",
"import/extensions": "off"
}
},
{
Expand Down
1 change: 0 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"parser": "babel",
"printWidth": 80,
"proseWrap": "never",
"requirePragma": false,
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ ENV NODE_ENV=production
COPY package.json package-lock.json index.js ./
RUN npm install --production
COPY --from=build $APP_HOME/dist ./dist
CMD ["npm", "run", "start:prod"]
CMD ["npm", "run", "start:prod"]
2 changes: 1 addition & 1 deletion client/common/Button.stories.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { action } from '@storybook/addon-actions';

import Button from './Button';
import { Button } from './Button';
import { GithubIcon, DropdownArrowIcon, PlusIcon } from './icons';

export default {
Expand Down
91 changes: 91 additions & 0 deletions client/common/Button.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import React from 'react';
import { render, screen, fireEvent } from '../test-utils';
import { Button } from './Button';

const MockIcon = (props: React.SVGProps<SVGSVGElement>) => (
<svg data-testid="mock-icon" {...props} />
);

describe('Button', () => {
// Tag
it('renders as an anchor when href is provided', () => {
render(<Button href="https://example.com">Link</Button>);
const anchor = screen.getByRole('link');
expect(anchor.tagName.toLowerCase()).toBe('a');
expect(anchor).toHaveAttribute('href', 'https://example.com');
});

it('renders as a React Router <Link> when `to` is provided', () => {
render(<Button to="/dashboard">Go</Button>);
const link = screen.getByRole('link');
expect(link.tagName.toLowerCase()).toBe('a'); // Link renders as <a>
expect(link).toHaveAttribute('href', '/dashboard');
});

it('renders as a <button> with a type of "button" by default', () => {
render(<Button>Click Me</Button>);
const el = screen.getByRole('button');
expect(el.tagName.toLowerCase()).toBe('button');
expect(el).toHaveAttribute('type', 'button');
});

// Children & Icons
it('renders children', () => {
render(<Button>Click Me</Button>);
expect(screen.getByText('Click Me')).toBeInTheDocument();
});

it('renders an iconBefore and button text', () => {
render(
<Button iconBefore={<MockIcon aria-label="iconbefore" />}>
This has a before icon
</Button>
);
expect(screen.getByLabelText('iconbefore')).toBeInTheDocument();
expect(screen.getByRole('button')).toHaveTextContent(
'This has a before icon'
);
});

it('renders with iconAfter', () => {
render(
<Button iconAfter={<MockIcon aria-label="iconafter" />}>
This has an after icon
</Button>
);
expect(screen.getByLabelText('iconafter')).toBeInTheDocument();
expect(screen.getByRole('button')).toHaveTextContent(
'This has an after icon'
);
});

it('renders only the icon if iconOnly', () => {
render(
<Button iconAfter={<MockIcon aria-label="iconafter" />} iconOnly>
This has an after icon
</Button>
);
expect(screen.getByLabelText('iconafter')).toBeInTheDocument();
expect(screen.getByRole('button')).not.toHaveTextContent(
'This has an after icon'
);
});

// HTML attributes
it('calls onClick handler when clicked', () => {
const handleClick = jest.fn();
render(<Button onClick={handleClick}>Click</Button>);
fireEvent.click(screen.getByText('Click'));
expect(handleClick).toHaveBeenCalledTimes(1);
});

it('renders disabled state', () => {
render(<Button disabled>Disabled</Button>);
expect(screen.getByRole('button')).toBeDisabled();
});

it('uses aria-label when provided', () => {
render(<Button aria-label="Upload" iconOnly />);
expect(screen.getByLabelText('Upload')).toBeInTheDocument();
});
});
193 changes: 99 additions & 94 deletions client/common/Button.jsx → client/common/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,93 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { Link } from 'react-router-dom';

import { remSize, prop } from '../theme';

const kinds = {
primary: 'primary',
secondary: 'secondary'
};
enum Kinds {
primary = 'primary',
secondary = 'secondary'
}

const displays = {
block: 'block',
inline: 'inline'
};
enum Displays {
block = 'block',
inline = 'inline'
}

enum ButtonTypes {
button = 'button',
submit = 'submit'
}

export interface ButtonProps extends React.HTMLAttributes<HTMLElement> {
/**
* The visible part of the button, telling the user what
* the action is
*/
children?: React.ReactNode;
/**
If the button can be activated or not
*/
disabled?: boolean;
/**
* The display type of the button—inline or block
*/
display?: Displays;
/**
* SVG icon to place after child content
*/
iconAfter?: React.ReactNode;
/**
* SVG icon to place before child content
*/
iconBefore?: React.ReactNode;
/**
* If the button content is only an SVG icon
*/
iconOnly?: boolean;
/**
* The kind of button - determines how it appears visually
*/
kind?: Kinds;
/**
* Specifying an href will use an <a> to link to the URL
*/
href?: string;
/**
* An ARIA Label used for accessibility
*/
'aria-label'?: string;
/**
* Specifying a to URL will use a react-router Link
*/
to?: string;
/**
* If using a native button, specifies on an onClick action
*/
onClick?: () => void;
/**
* If using a button, then type is defines the type of button
*/
type?: ButtonTypes;
/**
* Allows for IconButton to pass `focusable="false"` as a prop for SVGs.
* See @types/react > interface SVGAttributes<T> extends AriaAttributes, DOMAttributes<T>
*/
focusable?: boolean | 'true' | 'false';
}

interface StyledButtonProps extends ButtonProps {
kind: Kinds;
display: Displays;
}

// The '&&&' will increase the specificity of the
// component's CSS so that it overrides the more
// general global styles
const StyledButton = styled.button`
const StyledButton = styled.button<StyledButtonProps>`
&&& {
font-weight: bold;
display: ${({ display }) =>
display === displays.inline ? 'inline-flex' : 'flex'};
display === Displays.inline ? 'inline-flex' : 'flex'};
justify-content: center;
align-items: center;

Expand Down Expand Up @@ -109,35 +174,37 @@ const StyledInlineButton = styled.button`
`;

/**
* A Button performs an primary action
* Renders a component with a button appearance, but which is:
* - External anchor link if passed a `href`
* - Internal React Router link if passed a `to`
* - Default: Native Button
*/
const Button = ({
children,
display,
export const Button = ({
children = null,
display = Displays.block,
href,
kind,
iconBefore,
iconAfter,
iconOnly,
kind = Kinds.primary,
iconBefore = null,
iconAfter = null,
iconOnly = false,
'aria-label': ariaLabel,
to,
type,
type = ButtonTypes.button,
...props
}) => {
}: ButtonProps) => {
const hasChildren = React.Children.count(children) > 0;
const content = (
<>
{iconBefore}
{hasChildren && <span>{children}</span>}
{hasChildren && !iconOnly && <span>{children}</span>}
{iconAfter}
</>
);
let StyledComponent = StyledButton;

if (iconOnly) {
StyledComponent = StyledInlineButton;
}
const StyledComponent: React.ElementType = iconOnly
? StyledInlineButton
: StyledButton;

// Anchor Link
if (href) {
return (
<StyledComponent
Expand All @@ -153,6 +220,7 @@ const Button = ({
);
}

// Internal React Router Link
if (to) {
return (
<StyledComponent
Expand All @@ -168,6 +236,7 @@ const Button = ({
);
}

// Native Button
return (
<StyledComponent
kind={kind}
Expand All @@ -181,69 +250,5 @@ const Button = ({
);
};

Button.defaultProps = {
children: null,
disabled: false,
display: displays.block,
iconAfter: null,
iconBefore: null,
iconOnly: false,
kind: kinds.primary,
href: null,
'aria-label': null,
to: null,
type: 'button'
};

Button.kinds = kinds;
Button.displays = displays;

Button.propTypes = {
/**
* The visible part of the button, telling the user what
* the action is
*/
children: PropTypes.oneOfType([PropTypes.element, PropTypes.string]),
/**
If the button can be activated or not
*/
disabled: PropTypes.bool,
/**
* The display type of the button—inline or block
*/
display: PropTypes.oneOf(Object.values(displays)),
/**
* SVG icon to place after child content
*/
iconAfter: PropTypes.element,
/**
* SVG icon to place before child content
*/
iconBefore: PropTypes.element,
/**
* If the button content is only an SVG icon
*/
iconOnly: PropTypes.bool,
/**
* The kind of button - determines how it appears visually
*/
kind: PropTypes.oneOf(Object.values(kinds)),
/**
* Specifying an href will use an <a> to link to the URL
*/
href: PropTypes.string,
/**
* An ARIA Label used for accessibility
*/
'aria-label': PropTypes.string,
/**
* Specifying a to URL will use a react-router Link
*/
to: PropTypes.string,
/**
* If using a button, then type is defines the type of button
*/
type: PropTypes.oneOf(['button', 'submit'])
};

export default Button;
Button.kinds = Kinds;
Button.displays = Displays;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { render, screen, fireEvent, waitFor, history } from '../test-utils';
import ButtonOrLink from './ButtonOrLink';
import { ButtonOrLink } from './ButtonOrLink';

describe('ButtonOrLink', () => {
const clickHandler = jest.fn();
Expand Down
Loading
Loading