From 8c854960e54962cdb483125bd18218f495451aec Mon Sep 17 00:00:00 2001 From: jomcarvajal Date: Tue, 30 Sep 2025 13:49:41 -0600 Subject: [PATCH 01/10] create new MessageBox component --- src/components/Error.tsx | 18 +++++------------ src/components/MessageBox.spec.tsx | 25 +++++++++++++++++++++++ src/components/MessageBox.stories.tsx | 9 +++++++++ src/components/MessageBox.styles.tsx | 29 +++++++++++++++++++++++++++ src/components/MessageBox.tsx | 18 +++++++++++++++++ 5 files changed, 86 insertions(+), 13 deletions(-) create mode 100644 src/components/MessageBox.spec.tsx create mode 100644 src/components/MessageBox.stories.tsx create mode 100644 src/components/MessageBox.styles.tsx create mode 100644 src/components/MessageBox.tsx diff --git a/src/components/Error.tsx b/src/components/Error.tsx index a99cfa1a6..91bd468b6 100644 --- a/src/components/Error.tsx +++ b/src/components/Error.tsx @@ -1,8 +1,6 @@ import React from "react"; import * as Sentry from '@sentry/react'; -import { ModalBody, ModalBodyHeading } from "./Modal"; -import styled from "styled-components"; -import { colors } from "../../src/theme"; +import { BoxBody, BoxHeading, BoxEventId } from "./MessageBox.styles"; import { ErrorContext } from "../contexts"; export interface ErrorPropTypes { @@ -11,12 +9,6 @@ export interface ErrorPropTypes { heading?: string; } -const EventId = styled.div` - font-size: 1.4rem; - color: ${colors.palette.neutralMedium}; - margin-top: 1.6rem; -`; - export const Error = ({ heading, children, ...props }: ErrorPropTypes) => { const context = React.useContext(ErrorContext); const [lastEventId, setLastEventId] = React.useState(Sentry.lastEventId()); @@ -36,12 +28,12 @@ export const Error = ({ heading, children, ...props }: ErrorPropTypes) => { return () => clearInterval(intervalId); }, [lastEventId, context.error?.eventId]); - return - {heading ?? `Uh-oh, there's been a glitch`} + return + {heading ?? `Uh-oh, there's been a glitch`} {children ?? <> We're not quite sure what went wrong. Restart your browser. If this doesn't solve the problem, visit our Support Center. } - {context.error?.eventId || lastEventId} - + {context.error?.eventId || lastEventId} + }; diff --git a/src/components/MessageBox.spec.tsx b/src/components/MessageBox.spec.tsx new file mode 100644 index 000000000..992805ced --- /dev/null +++ b/src/components/MessageBox.spec.tsx @@ -0,0 +1,25 @@ +import renderer from 'react-test-renderer'; +import { MessageBox } from './MessageBox'; + +describe('MessageBox', () => { + it('matches snapshot', () => { + const tree = renderer.create( + + ).toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('can override text', () => { + const tree = renderer.create( + Body text + ).toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('can override margin', () => { + const tree = renderer.create( + Body text + ).toJSON(); + expect(tree).toMatchSnapshot(); + }); +}); diff --git a/src/components/MessageBox.stories.tsx b/src/components/MessageBox.stories.tsx new file mode 100644 index 000000000..6b8d4a35f --- /dev/null +++ b/src/components/MessageBox.stories.tsx @@ -0,0 +1,9 @@ +import { MessageBox } from './MessageBox'; + +export const Empty = () => ; +export const CustomText = () => + Diffferent body text +; +export const CustomMargin = () => + Diffferent margin +; diff --git a/src/components/MessageBox.styles.tsx b/src/components/MessageBox.styles.tsx new file mode 100644 index 000000000..4d6119e98 --- /dev/null +++ b/src/components/MessageBox.styles.tsx @@ -0,0 +1,29 @@ +import styled from "styled-components"; +import { colors } from "../../src/theme"; + +const modalPadding = 3; + +export const BoxWrapper = styled.div<{ + margin?: string; +}>` + margin: ${props => props.margin ?? '0 auto'}; + max-width: 90.2rem; + border: 0.1rem solid ${colors.palette.pale}; +`; + +export const BoxHeading = styled.h3` + font-weight: 400; + font-size: 2.2rem; + margin-top: 0; +`; + +export const BoxBody = styled.div` + font-size: 1.6rem; + padding: ${modalPadding}rem; +`; + +export const BoxEventId = styled.div` + font-size: 1.4rem; + color: ${colors.palette.neutralMedium}; + margin-top: 1.6rem; +`; \ No newline at end of file diff --git a/src/components/MessageBox.tsx b/src/components/MessageBox.tsx new file mode 100644 index 000000000..a24b3a2f2 --- /dev/null +++ b/src/components/MessageBox.tsx @@ -0,0 +1,18 @@ +import React from "react"; +import { BoxWrapper, BoxBody } from "./MessageBox.styles"; + +export interface MessageBoxProps { + margin?: string; + children?: React.ReactNode; +} + +export const MessageBox = ({ children, margin, ...props }: MessageBoxProps) => { + + return ( + + + {children} + + + ); +}; From 66129b276d2e4620d2c2894eeb07eb2a97228405 Mon Sep 17 00:00:00 2001 From: jomcarvajal Date: Tue, 30 Sep 2025 14:00:48 -0600 Subject: [PATCH 02/10] create new stores and snaps --- src/components/MessageBox.spec.tsx | 2 +- src/components/MessageBox.stories.tsx | 4 +- src/components/MessageBox.tsx | 6 +-- .../__snapshots__/Error.spec.tsx.snap | 12 +++--- .../__snapshots__/ErrorModal.spec.tsx.snap | 12 +++--- .../__snapshots__/MessageBox.spec.tsx.snap | 38 +++++++++++++++++++ 6 files changed, 56 insertions(+), 18 deletions(-) create mode 100644 src/components/__snapshots__/MessageBox.spec.tsx.snap diff --git a/src/components/MessageBox.spec.tsx b/src/components/MessageBox.spec.tsx index 992805ced..e0777ca3c 100644 --- a/src/components/MessageBox.spec.tsx +++ b/src/components/MessageBox.spec.tsx @@ -18,7 +18,7 @@ describe('MessageBox', () => { it('can override margin', () => { const tree = renderer.create( - Body text + Body text ).toJSON(); expect(tree).toMatchSnapshot(); }); diff --git a/src/components/MessageBox.stories.tsx b/src/components/MessageBox.stories.tsx index 6b8d4a35f..83d2f6aa3 100644 --- a/src/components/MessageBox.stories.tsx +++ b/src/components/MessageBox.stories.tsx @@ -4,6 +4,6 @@ export const Empty = () => ; export const CustomText = () => Diffferent body text ; -export const CustomMargin = () => - Diffferent margin +export const CustomMargin = () => + No submissions are currently available for review. ; diff --git a/src/components/MessageBox.tsx b/src/components/MessageBox.tsx index a24b3a2f2..13d565227 100644 --- a/src/components/MessageBox.tsx +++ b/src/components/MessageBox.tsx @@ -2,14 +2,14 @@ import React from "react"; import { BoxWrapper, BoxBody } from "./MessageBox.styles"; export interface MessageBoxProps { - margin?: string; + customMargin?: string; children?: React.ReactNode; } -export const MessageBox = ({ children, margin, ...props }: MessageBoxProps) => { +export const MessageBox = ({ children, customMargin, ...props }: MessageBoxProps) => { return ( - + {children} diff --git a/src/components/__snapshots__/Error.spec.tsx.snap b/src/components/__snapshots__/Error.spec.tsx.snap index 913e5e967..d81ab1f0f 100644 --- a/src/components/__snapshots__/Error.spec.tsx.snap +++ b/src/components/__snapshots__/Error.spec.tsx.snap @@ -2,17 +2,17 @@ exports[`Error can override text 1`] = `

An important heading

Body text
@@ -20,11 +20,11 @@ exports[`Error can override text 1`] = ` exports[`Error matches snapshot 1`] = `

Uh-oh, there's been a glitch

@@ -37,7 +37,7 @@ exports[`Error matches snapshot 1`] = ` .
diff --git a/src/components/__snapshots__/ErrorModal.spec.tsx.snap b/src/components/__snapshots__/ErrorModal.spec.tsx.snap index cf0bc9e34..f30af2d5a 100644 --- a/src/components/__snapshots__/ErrorModal.spec.tsx.snap +++ b/src/components/__snapshots__/ErrorModal.spec.tsx.snap @@ -86,11 +86,11 @@ exports[`Modal matches snapshot 1`] = `

Uh-oh, there's been a glitch

@@ -103,7 +103,7 @@ exports[`Modal matches snapshot 1`] = ` .
@@ -214,11 +214,11 @@ exports[`Modal matches snapshot when heading and children are set 1`] = `

Scores not sent

@@ -232,7 +232,7 @@ exports[`Modal matches snapshot when heading and children are set 1`] = ` .
diff --git a/src/components/__snapshots__/MessageBox.spec.tsx.snap b/src/components/__snapshots__/MessageBox.spec.tsx.snap new file mode 100644 index 000000000..8c7e8ca2e --- /dev/null +++ b/src/components/__snapshots__/MessageBox.spec.tsx.snap @@ -0,0 +1,38 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`MessageBox can override margin 1`] = ` +
+
+ Body text +
+
+`; + +exports[`MessageBox can override text 1`] = ` +
+
+ Body text +
+
+`; + +exports[`MessageBox matches snapshot 1`] = ` +
+
+
+`; From 58952037a43a5660cc7dccb3d05f77a54e522b67 Mon Sep 17 00:00:00 2001 From: jomcarvajal Date: Tue, 30 Sep 2025 14:01:31 -0600 Subject: [PATCH 03/10] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5effbe04e..d04714737 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openstax/ui-components", - "version": "1.18.5", + "version": "1.18.6", "license": "MIT", "source": "./src/index.ts", "types": "./dist/index.d.ts", From 6536094d533237da0a50bc324d4ad8a9e29a9a37 Mon Sep 17 00:00:00 2001 From: jomcarvajal Date: Tue, 30 Sep 2025 14:04:14 -0600 Subject: [PATCH 04/10] update jira-linked-action --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index cb4a2215f..a1c1b94de 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -10,7 +10,7 @@ jobs: name: Jira runs-on: ubuntu-latest steps: - - uses: openstax/jira-linked-action@v0.1.14 + - uses: openstax/jira-linked-action@v0.1.15 with: jira_site: openstax jira_project: DISCO From d777de1c1f2e32ccbea4c68daf9a510a352d2d70 Mon Sep 17 00:00:00 2001 From: jomcarvajal Date: Tue, 30 Sep 2025 14:10:03 -0600 Subject: [PATCH 05/10] remove unused ModalBodyHeading style --- src/components/Modal.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx index 703d8f8bf..a19f3f8f0 100644 --- a/src/components/Modal.tsx +++ b/src/components/Modal.tsx @@ -43,12 +43,6 @@ const Heading = styled(RAC.Heading)` font-size: 1.8rem; `; -export const ModalBodyHeading = styled.h3` - font-weight: 400; - font-size: 2.2rem; - margin-top: 0; -`; - export const ModalBody = styled.div` font-size: 1.6rem; padding: ${modalPadding}rem; From f7a650fea7cbde9045755af04b9e0e836b9e5fd0 Mon Sep 17 00:00:00 2001 From: jomcarvajal Date: Tue, 30 Sep 2025 14:14:32 -0600 Subject: [PATCH 06/10] update snaps --- .../__snapshots__/ErrorModal.spec.tsx.snap | 24 +++++++++---------- .../__snapshots__/Modal.spec.tsx.snap | 6 ++--- .../__snapshots__/Overlay.spec.tsx.snap | 8 +++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/components/__snapshots__/ErrorModal.spec.tsx.snap b/src/components/__snapshots__/ErrorModal.spec.tsx.snap index f30af2d5a..8f7cb629b 100644 --- a/src/components/__snapshots__/ErrorModal.spec.tsx.snap +++ b/src/components/__snapshots__/ErrorModal.spec.tsx.snap @@ -12,7 +12,7 @@ exports[`Modal matches snapshot 1`] = ` hidden="" />
@@ -31,7 +31,7 @@ exports[`Modal matches snapshot 1`] = ` />

Uh-oh, there's been a glitch

@@ -103,12 +103,12 @@ exports[`Modal matches snapshot 1`] = ` .