-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge release/2.5.0 into main branch (#1141)
* Converts RichTextEditor to TS, replaces templateVariables prop with customExtensions prop (#1121) * Convert Button to TS (#1138)
- Loading branch information
1 parent
a3b7bb4
commit 701ddcf
Showing
19 changed files
with
558 additions
and
576 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React, { forwardRef } from 'react'; | ||
import classNames from 'classnames'; | ||
import { IconDefinition } from '@fortawesome/fontawesome-svg-core'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { faSpinnerThird } from '@fortawesome/pro-regular-svg-icons'; | ||
|
||
import { | ||
Button as RBButton, | ||
type ButtonProps as RBButtonProps, | ||
} from 'react-bootstrap'; | ||
|
||
import './Button.scss'; | ||
|
||
export enum ButtonSizes { | ||
SMALL = 'sm', | ||
MEDIUM = 'md', | ||
LARGE = 'lg', | ||
} | ||
|
||
export enum ButtonVariants { | ||
BRAND_GOOGLE = 'brand-google', | ||
BRAND_FACEBOOK = 'brand-facebook', | ||
BRAND_LINKEDIN = 'brand-linkedin', | ||
BRAND_TWITTER = 'brand-twitter', | ||
DANGER = 'danger', | ||
LINK = 'link', | ||
OUTLINE_DANGER = 'outline-danger', | ||
OUTLINE_PRIMARY = 'outline-primary', | ||
OUTLINE_WARNING = 'outline-warning', | ||
OUTLINE_TRANSPARENT = 'outline-transparent', | ||
PRIMARY = 'primary', | ||
TRANSPARENT = 'transparent', | ||
WARNING = 'warning', | ||
} | ||
|
||
export type ButtonProps = RBButtonProps & { | ||
isLoading?: boolean; | ||
leadingIcon?: IconDefinition; | ||
loadingText?: string; | ||
trailingIcon?: IconDefinition; | ||
} | ||
|
||
const Button = forwardRef<HTMLElement, ButtonProps>(({ | ||
children, | ||
className, | ||
disabled, | ||
isLoading, | ||
leadingIcon, | ||
loadingText = 'Loading...', | ||
trailingIcon, | ||
...props | ||
}, ref) => ( | ||
<RBButton | ||
aria-disabled={disabled || isLoading} | ||
className={classNames('Button', className)} | ||
disabled={disabled || isLoading} | ||
ref={ref} | ||
{...props} | ||
> | ||
{ !isLoading ? ( | ||
<> | ||
{ leadingIcon && (<FontAwesomeIcon className="icon-left" icon={leadingIcon} />)} | ||
{ children } | ||
{ trailingIcon && (<FontAwesomeIcon className="icon-right" icon={trailingIcon} />)} | ||
</> | ||
) : ( | ||
<> | ||
<FontAwesomeIcon className="icon-left btn-loading-spin" icon={faSpinnerThird as IconDefinition} /> | ||
{loadingText} | ||
</> | ||
)} | ||
</RBButton> | ||
)); | ||
|
||
export default Button; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
|
||
import RichTextEditor, { type RichTextEditorProps } from './RichTextEditor'; | ||
|
||
describe('<RichTextEditor />', () => { | ||
const Setup = (overrides: Omit<RichTextEditorProps, 'id' | 'onChange'> = {}) => ( | ||
<RichTextEditor | ||
id="some-id" | ||
onChange={jest.fn()} | ||
{...overrides} | ||
/> | ||
); | ||
|
||
it('renders snapshot', () => { | ||
const { asFragment } = render(<Setup />); | ||
|
||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
describe('given an initial value', () => { | ||
it('deserializes value correctly', () => { | ||
render(<Setup initialValue="<p>hello world</p>" />); | ||
|
||
expect(screen.getByText('hello world')).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.