From 24e03d32d88a66c1efa79c12bef15b1e00d8720a Mon Sep 17 00:00:00 2001 From: Brett Dorrans Date: Sat, 1 Oct 2022 11:57:21 +0100 Subject: [PATCH] Feat/improvepanel (#1226) * feat: add tag prop to Panel * feat: add buttons prop to Panel * feat: add dismissable prop to Panel * feat: give Panel better status styles * test: improve coverage of Panel dismissable * feat: refactor a bit * test: improve coverage --- src/components/button/Button.spec.tsx | 6 +- .../button/__snapshots__/Button.spec.tsx.snap | 107 +- src/components/button/styles.ts | 4 +- src/components/index.ts | 1 - src/components/panel/Panel.spec.tsx | 58 +- src/components/panel/Panel.stories.tsx | 149 ++- .../panel/__snapshots__/Panel.spec.tsx.snap | 1159 ++++++++++++++++- .../panel-actions/PanelActions.spec.tsx | 59 + .../__snapshots__/PanelActions.spec.tsx.snap | 601 +++++++++ .../panel/components/panel-actions/index.tsx | 26 + .../panel/components/panel-actions/styles.ts | 11 + .../components/panel-body/PanelBody.spec.tsx | 49 + .../__snapshots__/PanelBody.spec.tsx.snap | 94 ++ .../panel/components/panel-body/index.tsx | 37 + .../panel/components/panel-body/styles.ts | 27 + .../panel-buttons/PanelButtons.spec.tsx | 35 + .../__snapshots__/PanelButtons.spec.tsx.snap | 201 +++ .../panel/components/panel-buttons/index.tsx | 23 + .../panel/components/panel-buttons/styles.ts | 8 + .../panel-icons/PanelIcons.spec.tsx | 41 + .../__snapshots__/PanelIcons.spec.tsx.snap | 239 ++++ .../panel/components/panel-icons/index.tsx | 55 + .../panel/components/panel-icons/styles.ts | 40 + src/components/panel/index.tsx | 105 +- src/components/panel/styles.ts | 60 +- .../status-message/StatusMessage.spec.tsx | 54 - .../status-message/StatusMessage.stories.tsx | 73 -- .../__snapshots__/StatusMessage.spec.tsx.snap | 416 ------ src/components/status-message/index.tsx | 101 -- src/components/status-message/styles.ts | 69 - src/components/text/Text.spec.tsx | 2 +- .../text/__snapshots__/Text.spec.tsx.snap | 8 +- .../toggle/__snapshots__/Toggle.spec.tsx.snap | 88 +- 33 files changed, 3075 insertions(+), 931 deletions(-) create mode 100644 src/components/panel/components/panel-actions/PanelActions.spec.tsx create mode 100644 src/components/panel/components/panel-actions/__snapshots__/PanelActions.spec.tsx.snap create mode 100644 src/components/panel/components/panel-actions/index.tsx create mode 100644 src/components/panel/components/panel-actions/styles.ts create mode 100644 src/components/panel/components/panel-body/PanelBody.spec.tsx create mode 100644 src/components/panel/components/panel-body/__snapshots__/PanelBody.spec.tsx.snap create mode 100644 src/components/panel/components/panel-body/index.tsx create mode 100644 src/components/panel/components/panel-body/styles.ts create mode 100644 src/components/panel/components/panel-buttons/PanelButtons.spec.tsx create mode 100644 src/components/panel/components/panel-buttons/__snapshots__/PanelButtons.spec.tsx.snap create mode 100644 src/components/panel/components/panel-buttons/index.tsx create mode 100644 src/components/panel/components/panel-buttons/styles.ts create mode 100644 src/components/panel/components/panel-icons/PanelIcons.spec.tsx create mode 100644 src/components/panel/components/panel-icons/__snapshots__/PanelIcons.spec.tsx.snap create mode 100644 src/components/panel/components/panel-icons/index.tsx create mode 100644 src/components/panel/components/panel-icons/styles.ts delete mode 100644 src/components/status-message/StatusMessage.spec.tsx delete mode 100644 src/components/status-message/StatusMessage.stories.tsx delete mode 100644 src/components/status-message/__snapshots__/StatusMessage.spec.tsx.snap delete mode 100644 src/components/status-message/index.tsx delete mode 100644 src/components/status-message/styles.ts diff --git a/src/components/button/Button.spec.tsx b/src/components/button/Button.spec.tsx index 3c28da08..36e174d8 100644 --- a/src/components/button/Button.spec.tsx +++ b/src/components/button/Button.spec.tsx @@ -21,7 +21,7 @@ test('it works', () => { test('it works with size small', () => { const { container } = setup( - ); @@ -30,7 +30,7 @@ test('it works with size small', () => { test('it works with size medium', () => { const { container } = setup( - ); @@ -39,7 +39,7 @@ test('it works with size medium', () => { test('it works with size large', () => { const { container } = setup( - ); diff --git a/src/components/button/__snapshots__/Button.spec.tsx.snap b/src/components/button/__snapshots__/Button.spec.tsx.snap index 39a3b594..8f67acd8 100644 --- a/src/components/button/__snapshots__/Button.spec.tsx.snap +++ b/src/components/button/__snapshots__/Button.spec.tsx.snap @@ -11,8 +11,8 @@ exports[`it works 1`] = ` border-radius: 0.3rem; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; background-color: #17a3a5; @@ -49,8 +49,8 @@ exports[`it works 1`] = ` border-radius: 0.3rem; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; background-color: #17a3a5; @@ -110,11 +110,11 @@ exports[`it works with anchor 1`] = ` border-radius: 0.3rem; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #17a3a5; border-color: #d4d4d4; } @@ -148,11 +148,11 @@ exports[`it works with anchor 1`] = ` border-radius: 0.3rem; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #17a3a5; border-color: #d4d4d4; } @@ -210,11 +210,11 @@ exports[`it works with icon 1`] = ` border-radius: 0.3rem; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #17a3a5; border-color: #d4d4d4; } @@ -248,11 +248,11 @@ exports[`it works with icon 1`] = ` border-radius: 0.3rem; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #17a3a5; border-color: #d4d4d4; } @@ -325,11 +325,11 @@ exports[`it works with loading 1`] = ` border-radius: 0.3rem; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #17a3a5; border-color: #d4d4d4; } @@ -363,11 +363,11 @@ exports[`it works with loading 1`] = ` border-radius: 0.3rem; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #17a3a5; border-color: #d4d4d4; } @@ -502,11 +502,11 @@ exports[`it works with size large 1`] = ` border-radius: 0.3rem; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #17a3a5; border-color: #d4d4d4; } @@ -540,11 +540,11 @@ exports[`it works with size large 1`] = ` border-radius: 0.3rem; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #17a3a5; border-color: #d4d4d4; } @@ -580,7 +580,6 @@ exports[`it works with size large 1`] = ` + + `; -exports[`it works with elevation 2`] = ` +exports[`it works with dismissable 1`] = ` .c0 { + border-style: solid; border-radius: 0.3rem; - box-shadow: 0 2px 4px rgba(0,0,0,0.12),0 10px 13px rgba(0,0,0,0.02),0 -10px 13px rgba(0,0,0,0.02); + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); min-height: 8rem; + background-color: white; + border-color: transparent; +} + +.c1 { + position: relative; +} + +.c2 { + font-size: 1rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 2; + max-width: 91.666667%; + margin-top: 0.5rem; + margin-bottom: 0.5rem; padding-left: 1rem; padding-right: 1rem; - padding-top: 0.75rem; - padding-bottom: 0.75rem; + padding-left: 1rem; + color: #292B3E; +} + +.c4 { + border-style: solid; + text-align: center; + display: inline-block; + position: absolute; + top: 0; + right: 0; + font-size: 1rem; + font-weight: 500; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + margin-top: 1.5rem; + margin-right: 1.5rem; + padding-left: 0.75rem; + padding-right: 0.75rem; + padding-top: 0.5rem; + padding-bottom: 0.5rem; + background-color: white; + color: #73748b; + border-color: #fafafa; +} + +.c4:hover { + cursor: pointer; + background-color: #fafafa; + color: #292B3E; +} + +.c4:hover:disabled { + cursor: not-allowed; + background-color: #fafafa; +} + +.c4:disabled { + opacity: 0.7; + background-color: #fafafa; + color: #292B3E; +} + +.c3 { + border-style: solid; + text-align: center; + display: inline-block; + position: absolute; + top: 0; + right: 0; + font-size: 1rem; + font-weight: 500; + font-family: Montserrat,sans-serif; + line-height: 2; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + margin-top: 1.5rem; + margin-right: 1.5rem; + padding-left: 0.75rem; + padding-right: 0.75rem; + padding-top: 0.5rem; + padding-bottom: 0.5rem; background-color: white; + color: #73748b; + border-color: #fafafa; +} + +.c3:hover { + cursor: pointer; + background-color: #fafafa; + color: #292B3E; +} + +.c3:hover:disabled { + cursor: not-allowed; + background-color: #fafafa; +} + +.c3:disabled { + opacity: 0.7; + background-color: #fafafa; + color: #292B3E; +} + +.c5 { + opacity: 1; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; }
- Hello world +
+

+ body +

+
+
`; -exports[`it works with elevation 3`] = ` +exports[`it works with elevation 1`] = ` .c0 { + border-style: solid; border-radius: 0.3rem; - box-shadow: 0 2px 5px rgba(0,0,0,0.16),-10px 15px 15px rgba(0,0,0,0.03),10px 0px 15px rgba(0,0,0,0.03); + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); min-height: 8rem; + background-color: white; + border-color: transparent; +} + +.c1 { + position: relative; +} + +.c2 { + font-size: 1rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 2; + max-width: 91.666667%; + margin-top: 0.5rem; + margin-bottom: 0.5rem; padding-left: 1rem; padding-right: 1rem; - padding-top: 0.75rem; - padding-bottom: 0.75rem; - background-color: white; + padding-left: 1rem; + color: #292B3E; }
- Hello world +
+

+ Hello world +

+
`; -exports[`it works with elevation 4`] = ` +exports[`it works with elevation 2`] = ` +.c1 { + position: relative; +} + +.c2 { + font-size: 1rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 2; + max-width: 91.666667%; + margin-top: 0.5rem; + margin-bottom: 0.5rem; + padding-left: 1rem; + padding-right: 1rem; + padding-left: 1rem; + color: #292B3E; +} + .c0 { + border-style: solid; border-radius: 0.3rem; - box-shadow: 0 2px 6px rgba(0,0,0,0.18),-15px 20px 20px rgba(0,0,0,0.04),15px -5px 20px rgba(0,0,0,0.04); + border-width: 2px; + box-shadow: 0 2px 4px rgba(0,0,0,0.12),0 10px 13px rgba(0,0,0,0.02),0 -10px 13px rgba(0,0,0,0.02); min-height: 8rem; - padding-left: 1rem; - padding-right: 1rem; - padding-top: 0.75rem; - padding-bottom: 0.75rem; background-color: white; + border-color: transparent; }
- Hello world +
+

+ Hello world +

+
`; -exports[`it works with heading 1`] = ` -.c0 { - border-radius: 0.3rem; - box-shadow: 0 2px 3px rgba(0,0,0,0.1); - min-height: 8rem; - padding-left: 1rem; - padding-right: 1rem; - padding-top: 0.75rem; - padding-bottom: 0.75rem; - background-color: white; +exports[`it works with elevation 3`] = ` +.c1 { + position: relative; } -.c1 { - font-size: 1.875rem; - font-weight: 700; +.c2 { + font-size: 1rem; + font-weight: 400; font-family: Montserrat,sans-serif; - line-height: 1.25; - margin-bottom: 1rem; + line-height: 2; + max-width: 91.666667%; + margin-top: 0.5rem; + margin-bottom: 0.5rem; + padding-left: 1rem; + padding-right: 1rem; + padding-left: 1rem; color: #292B3E; } -
-

+
+

+ Hello world +

+
+

+`; + +exports[`it works with elevation 4`] = ` +.c1 { + position: relative; +} + +.c2 { + font-size: 1rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 2; + max-width: 91.666667%; + margin-top: 0.5rem; + margin-bottom: 0.5rem; + padding-left: 1rem; + padding-right: 1rem; + padding-left: 1rem; + color: #292B3E; +} + +.c0 { + border-style: solid; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 6px rgba(0,0,0,0.18),-15px 20px 20px rgba(0,0,0,0.04),15px -5px 20px rgba(0,0,0,0.04); + min-height: 8rem; + background-color: white; + border-color: transparent; +} + +
+
+

+ Hello world +

+
+
+`; + +exports[`it works with heading 1`] = ` +.c0 { + border-style: solid; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + min-height: 8rem; + background-color: white; + border-color: transparent; +} + +.c1 { + position: relative; +} + +.c2 { + font-size: 1.875rem; + font-weight: 700; + font-family: Montserrat,sans-serif; + line-height: 1.25; + padding: 1rem; + padding-top: 1rem; + padding-bottom: 0; + padding-left: 1rem; + color: #292B3E; +} + +.c3 { + font-size: 1rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 2; + max-width: 91.666667%; + margin-top: 0.5rem; + margin-bottom: 0.5rem; + padding-left: 1rem; + padding-right: 1rem; + padding-left: 1rem; + color: #292B3E; +} + +
+
+

+ heading +

+

+ body +

+
+
+`; + +exports[`it works with image 1`] = ` +.c0 { + border-style: solid; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + min-height: 8rem; + background-color: white; + border-color: transparent; +} + +.c1 { + border-bottom-style: solid; + border-bottom-width: 4px; + width: 100%; + margin-bottom: 0.5rem; + border-bottom-color: #fafafa; +} + +.c2 { + position: relative; +} + +.c3 { + font-size: 1rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 2; + max-width: 91.666667%; + margin-top: 0.5rem; + margin-bottom: 0.5rem; + padding-left: 1rem; + padding-right: 1rem; + padding-left: 1rem; + color: #292B3E; +} + +
+ test +
+

+ Hello world +

+
+
+`; + +exports[`it works with status 1`] = ` +.c0 { + border-style: solid; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + min-height: 8rem; + background-color: white; + border-color: transparent; +} + +.c1 { + position: relative; +} + +.c2 { + font-size: 1rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 2; + max-width: 91.666667%; + margin-top: 0.5rem; + margin-bottom: 0.5rem; + padding-left: 1rem; + padding-right: 1rem; + padding-left: 1rem; + color: #292B3E; +} + +
+
+

+ Hello world +

+
+
+`; + +exports[`it works with status 2`] = ` +.c1 { + position: relative; +} + +.c2 { + font-size: 1rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 2; + max-width: 91.666667%; + margin-top: 0.5rem; + margin-bottom: 0.5rem; + padding-left: 1rem; + padding-right: 1rem; + padding-left: 1rem; + color: #292B3E; +} + +.c0 { + border-style: solid; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + min-height: 8rem; + background-color: white; + border-color: #73748b; +} + +.c3 { + border-top-style: solid; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + border-top-width: 4px; + -webkit-align-items: flex-end; + -webkit-box-align: flex-end; + -ms-flex-align: flex-end; + align-items: flex-end; + margin-top: 0.5rem; + padding: 1rem; + border-top-color: #fafafa; +} + +.c4 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c5 { + font-size: 1.875rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 0; + border-radius: 9999px; + margin-right: 1rem; + background-color: white; + color: #73748b; +} + +
+
+

+ Hello world +

+
+
+
+

+ +

+
+
+
+`; + +exports[`it works with status 3`] = ` +.c1 { + position: relative; +} + +.c2 { + font-size: 1rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 2; + max-width: 91.666667%; + margin-top: 0.5rem; + margin-bottom: 0.5rem; + padding-left: 1rem; + padding-right: 1rem; + padding-left: 1rem; + color: #292B3E; +} + +.c3 { + border-top-style: solid; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + border-top-width: 4px; + -webkit-align-items: flex-end; + -webkit-box-align: flex-end; + -ms-flex-align: flex-end; + align-items: flex-end; + margin-top: 0.5rem; + padding: 1rem; + border-top-color: #fafafa; +} + +.c4 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c0 { + border-style: solid; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + min-height: 8rem; + background-color: white; + border-color: #ebc764; +} + +.c5 { + font-size: 1.875rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 0; + border-radius: 9999px; + margin-right: 1rem; + background-color: white; + color: #ebc764; +} + +
+
+

+ Hello world +

+
+
+
+

+ +

+
+
+
+`; + +exports[`it works with status 4`] = ` +.c1 { + position: relative; +} + +.c2 { + font-size: 1rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 2; + max-width: 91.666667%; + margin-top: 0.5rem; + margin-bottom: 0.5rem; + padding-left: 1rem; + padding-right: 1rem; + padding-left: 1rem; + color: #292B3E; +} + +.c3 { + border-top-style: solid; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + border-top-width: 4px; + -webkit-align-items: flex-end; + -webkit-box-align: flex-end; + -ms-flex-align: flex-end; + align-items: flex-end; + margin-top: 0.5rem; + padding: 1rem; + border-top-color: #fafafa; +} + +.c4 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c0 { + border-style: solid; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + min-height: 8rem; + background-color: white; + border-color: #b41e25; +} + +.c5 { + font-size: 1.875rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 0; + border-radius: 9999px; + margin-right: 1rem; + background-color: white; + color: #b41e25; +} + +
+
+

+ Hello world +

+
+
+
+

+ +

+
+
+
+`; + +exports[`it works with tag 1`] = ` +.c0 { + border-style: solid; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + min-height: 8rem; + background-color: white; + border-color: transparent; +} + +.c1 { + position: relative; +} + +.c2 { + font-size: 1rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 2; + max-width: 91.666667%; + margin-top: 0.5rem; + margin-bottom: 0.5rem; + padding-left: 1rem; + padding-right: 1rem; + padding-left: 1rem; + color: #292B3E; +} + +.c3 { + border-top-style: solid; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + border-top-width: 4px; + -webkit-align-items: flex-end; + -webkit-box-align: flex-end; + -ms-flex-align: flex-end; + align-items: flex-end; + margin-top: 0.5rem; + padding: 1rem; + border-top-color: #fafafa; +} + +.c4 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c5 { + -webkit-flex: 1 1 auto; + -ms-flex: 1 1 auto; + flex: 1 1 auto; +} + +.c6 { + border-style: solid; + text-align: center; + font-size: 0.75rem; + font-weight: 500; + font-family: Montserrat,sans-serif; + line-height: 2; + border-radius: 0.6rem; + border-width: 0; + padding-top: 0.25rem; + padding-bottom: 0.25rem; + background-color: #135f61; + color: white; + border-color: #292B3E; +} + +.c7 { + padding-left: 0.5rem; + padding-right: 0.5rem; + padding-top: 0.25rem; + padding-bottom: 0.25rem; +} + +
+
- heading - - body +

+ body +

+
+
+
+
+ + + v1.0.0 + + +
+
+
`; diff --git a/src/components/panel/components/panel-actions/PanelActions.spec.tsx b/src/components/panel/components/panel-actions/PanelActions.spec.tsx new file mode 100644 index 00000000..0211c2e8 --- /dev/null +++ b/src/components/panel/components/panel-actions/PanelActions.spec.tsx @@ -0,0 +1,59 @@ +import * as React from 'react'; +import { render } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import 'jest-styled-components'; + +import { ThemeProvider } from '../../../theme-provider'; +import { PanelActions } from './index'; +import { PanelStatusType } from '../../index'; + +const setup = (panel: React.ReactElement) => + render({panel}); + +const defaultProps = { + tag: undefined, + buttons: undefined, + status: undefined +}; + +test('it works', () => { + const { container } = setup(); + expect(container.firstChild).toMatchSnapshot(); +}); + +test('it works with tag', () => { + const { container, getByText } = setup( + + ); + expect(container.firstChild).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); + expect(getByText('v1.0.0')).toBeTruthy(); +}); + +test('it works with buttons', () => { + const { container, getByText, getAllByRole } = setup( + + ); + expect(container.firstChild).toMatchSnapshot(); + expect(getByText('Button 1')).toBeTruthy(); + expect(getByText('Button 2')).toBeTruthy(); + expect(getAllByRole('button').length).toBe(2); +}); + +test('it works with status', () => { + const statuses: PanelStatusType[] = ['none', 'info', 'warning', 'error']; + + statuses.forEach((status) => { + const { container } = setup(); + expect(container.firstChild).toMatchSnapshot(); + }); +}); diff --git a/src/components/panel/components/panel-actions/__snapshots__/PanelActions.spec.tsx.snap b/src/components/panel/components/panel-actions/__snapshots__/PanelActions.spec.tsx.snap new file mode 100644 index 00000000..d29369c4 --- /dev/null +++ b/src/components/panel/components/panel-actions/__snapshots__/PanelActions.spec.tsx.snap @@ -0,0 +1,601 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`it works 1`] = `null`; + +exports[`it works with buttons 1`] = ` +.c0 { + border-top-style: solid; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + border-top-width: 4px; + -webkit-align-items: flex-end; + -webkit-box-align: flex-end; + -ms-flex-align: flex-end; + align-items: flex-end; + margin-top: 0.5rem; + padding: 1rem; + border-top-color: #fafafa; +} + +.c1 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c2 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + width: 100%; + -webkit-box-pack: end; + -webkit-justify-content: end; + -ms-flex-pack: end; + justify-content: end; + gap: 0.5rem; +} + +.c4 { + border-style: solid; + text-align: center; + display: inline-block; + position: relative; + font-size: 1rem; + font-weight: 500; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + padding-left: 0.75rem; + padding-right: 0.75rem; + padding-top: 0.5rem; + padding-bottom: 0.5rem; + background-color: #17a3a5; + color: white; + border-color: #17a3a5; +} + +.c4:hover { + cursor: pointer; + background-color: #135f61; + color: white; +} + +.c4:hover:disabled { + cursor: not-allowed; + background-color: #135f61; +} + +.c4:disabled { + opacity: 0.7; + background-color: #135f61; + color: white; +} + +.c3 { + border-style: solid; + text-align: center; + display: inline-block; + position: relative; + font-size: 1rem; + font-weight: 500; + font-family: Montserrat,sans-serif; + line-height: 2; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + padding-left: 0.75rem; + padding-right: 0.75rem; + padding-top: 0.5rem; + padding-bottom: 0.5rem; + background-color: #17a3a5; + color: white; + border-color: #17a3a5; +} + +.c3:hover { + cursor: pointer; + background-color: #135f61; + color: white; +} + +.c3:hover:disabled { + cursor: not-allowed; + background-color: #135f61; +} + +.c3:disabled { + opacity: 0.7; + background-color: #135f61; + color: white; +} + +.c5 { + opacity: 1; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c7 { + border-style: solid; + text-align: center; + display: inline-block; + position: relative; + font-size: 1rem; + font-weight: 500; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + padding-left: 0.75rem; + padding-right: 0.75rem; + padding-top: 0.5rem; + padding-bottom: 0.5rem; + background-color: white; + color: #17a3a5; + border-color: #d4d4d4; +} + +.c7:hover { + cursor: pointer; + background-color: #fafafa; + color: #135f61; +} + +.c7:hover:disabled { + cursor: not-allowed; + background-color: #fafafa; +} + +.c7:disabled { + opacity: 0.7; + background-color: #fafafa; + color: #292B3E; +} + +.c6 { + border-style: solid; + text-align: center; + display: inline-block; + position: relative; + font-size: 1rem; + font-weight: 500; + font-family: Montserrat,sans-serif; + line-height: 2; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + padding-left: 0.75rem; + padding-right: 0.75rem; + padding-top: 0.5rem; + padding-bottom: 0.5rem; + background-color: white; + color: #17a3a5; + border-color: #d4d4d4; +} + +.c6:hover { + cursor: pointer; + background-color: #fafafa; + color: #135f61; +} + +.c6:hover:disabled { + cursor: not-allowed; + background-color: #fafafa; +} + +.c6:disabled { + opacity: 0.7; + background-color: #fafafa; + color: #292B3E; +} + +
+
+
+ + +
+
+`; + +exports[`it works with status 1`] = `null`; + +exports[`it works with status 2`] = ` +.c0 { + border-top-style: solid; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + border-top-width: 4px; + -webkit-align-items: flex-end; + -webkit-box-align: flex-end; + -ms-flex-align: flex-end; + align-items: flex-end; + margin-top: 0.5rem; + padding: 1rem; + border-top-color: #fafafa; +} + +.c1 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c2 { + font-size: 1.875rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 0; + border-radius: 9999px; + margin-right: 1rem; + background-color: white; + color: #73748b; +} + +
+
+

+ +

+
+
+`; + +exports[`it works with status 3`] = ` +.c0 { + border-top-style: solid; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + border-top-width: 4px; + -webkit-align-items: flex-end; + -webkit-box-align: flex-end; + -ms-flex-align: flex-end; + align-items: flex-end; + margin-top: 0.5rem; + padding: 1rem; + border-top-color: #fafafa; +} + +.c1 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c2 { + font-size: 1.875rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 0; + border-radius: 9999px; + margin-right: 1rem; + background-color: white; + color: #ebc764; +} + +
+
+

+ +

+
+
+`; + +exports[`it works with status 4`] = ` +.c0 { + border-top-style: solid; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + border-top-width: 4px; + -webkit-align-items: flex-end; + -webkit-box-align: flex-end; + -ms-flex-align: flex-end; + align-items: flex-end; + margin-top: 0.5rem; + padding: 1rem; + border-top-color: #fafafa; +} + +.c1 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c2 { + font-size: 1.875rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 0; + border-radius: 9999px; + margin-right: 1rem; + background-color: white; + color: #b41e25; +} + +
+
+

+ +

+
+
+`; + +exports[`it works with tag 1`] = ` +.c0 { + border-top-style: solid; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + border-top-width: 4px; + -webkit-align-items: flex-end; + -webkit-box-align: flex-end; + -ms-flex-align: flex-end; + align-items: flex-end; + margin-top: 0.5rem; + padding: 1rem; + border-top-color: #fafafa; +} + +.c1 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c2 { + -webkit-flex: 1 1 auto; + -ms-flex: 1 1 auto; + flex: 1 1 auto; +} + +.c3 { + border-style: solid; + text-align: center; + font-size: 0.75rem; + font-weight: 500; + font-family: Montserrat,sans-serif; + line-height: 2; + border-radius: 0.6rem; + border-width: 0; + padding-top: 0.25rem; + padding-bottom: 0.25rem; + background-color: #135f61; + color: white; + border-color: #292B3E; +} + +.c4 { + padding-left: 0.5rem; + padding-right: 0.5rem; + padding-top: 0.25rem; + padding-bottom: 0.25rem; +} + +
+
+
+ + + v1.0.0 + + +
+
+
+`; + +exports[`it works with tag 2`] = ` +.c0 { + border-top-style: solid; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + border-top-width: 4px; + -webkit-align-items: flex-end; + -webkit-box-align: flex-end; + -ms-flex-align: flex-end; + align-items: flex-end; + margin-top: 0.5rem; + padding: 1rem; + border-top-color: #fafafa; +} + +.c1 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c2 { + -webkit-flex: 1 1 auto; + -ms-flex: 1 1 auto; + flex: 1 1 auto; +} + +.c3 { + border-style: solid; + text-align: center; + font-size: 0.75rem; + font-weight: 500; + font-family: Montserrat,sans-serif; + line-height: 2; + border-radius: 0.6rem; + border-width: 0; + padding-top: 0.25rem; + padding-bottom: 0.25rem; + background-color: #135f61; + color: white; + border-color: #292B3E; +} + +.c4 { + padding-left: 0.5rem; + padding-right: 0.5rem; + padding-top: 0.25rem; + padding-bottom: 0.25rem; +} + +
+
+
+ + + v1.0.0 + + +
+
+
+`; diff --git a/src/components/panel/components/panel-actions/index.tsx b/src/components/panel/components/panel-actions/index.tsx new file mode 100644 index 00000000..838ca879 --- /dev/null +++ b/src/components/panel/components/panel-actions/index.tsx @@ -0,0 +1,26 @@ +import * as React from 'react'; +import { Box } from '../../../box'; +import { PanelProps } from '../../index'; +import { panelActionsStyles } from './styles'; +import { PanelIcons } from '../panel-icons'; +import { PanelButtons } from '../panel-buttons'; + +export const PanelActions: React.FC< + Pick +> = ({ tag, buttons, status }) => { + const hasTag = tag?.title; + const hasButtons = buttons?.length; + const hasStatus = status && status !== 'none'; + const canRender = hasTag || hasButtons || hasStatus; + + if (!canRender) return null; + + return ( + + + + + ); +}; + +PanelActions.displayName = 'PanelActions'; diff --git a/src/components/panel/components/panel-actions/styles.ts b/src/components/panel/components/panel-actions/styles.ts new file mode 100644 index 00000000..3713b23d --- /dev/null +++ b/src/components/panel/components/panel-actions/styles.ts @@ -0,0 +1,11 @@ +import { Styles } from '@lapidist/styles'; + +export const panelActionsStyles = (): Styles => ({ + display: 'flex', + alignItems: 'flex-end', + borderTopColor: { group: 'grey', shade: 'lightest' }, + borderTopStyle: 'solid', + borderTopWidth: '2', + padding: '4', + marginTop: '2' +}); diff --git a/src/components/panel/components/panel-body/PanelBody.spec.tsx b/src/components/panel/components/panel-body/PanelBody.spec.tsx new file mode 100644 index 00000000..d693b28b --- /dev/null +++ b/src/components/panel/components/panel-body/PanelBody.spec.tsx @@ -0,0 +1,49 @@ +import * as React from 'react'; +import { render } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import 'jest-styled-components'; + +import { ThemeProvider } from '../../../theme-provider'; +import { PanelBody } from './index'; + +const setup = (panel: React.ReactElement) => + render({panel}); + +const defaultProps = { + image: undefined, + heading: undefined +}; + +test('it works', () => { + const { container, getByText } = setup( + body + ); + expect(container.firstChild).toMatchSnapshot(); + expect(getByText('body')).toBeTruthy(); +}); + +test('it works with image', () => { + const { container, getByText, getByAltText } = setup( + + body + + ); + expect(container.firstChild).toMatchSnapshot(); + expect(getByText('body')).toBeTruthy(); + expect(getByAltText('test')).toBeTruthy(); +}); + +test('it works with heading', () => { + const { container, getByText } = setup( + + body + + ); + expect(container.firstChild).toMatchSnapshot(); + expect(getByText('heading')).toBeTruthy(); + expect(getByText('body')).toBeTruthy(); + expect(container.querySelectorAll('h2').length).toBe(1); +}); diff --git a/src/components/panel/components/panel-body/__snapshots__/PanelBody.spec.tsx.snap b/src/components/panel/components/panel-body/__snapshots__/PanelBody.spec.tsx.snap new file mode 100644 index 00000000..6a542e24 --- /dev/null +++ b/src/components/panel/components/panel-body/__snapshots__/PanelBody.spec.tsx.snap @@ -0,0 +1,94 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`it works 1`] = ` +.c0 { + position: relative; +} + +.c1 { + font-size: 1rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 2; + max-width: 91.666667%; + margin-top: 0.5rem; + margin-bottom: 0.5rem; + padding-left: 1rem; + padding-right: 1rem; + padding-left: 1rem; + color: #292B3E; +} + +
+

+ body +

+
+`; + +exports[`it works with heading 1`] = ` +.c0 { + position: relative; +} + +.c1 { + font-size: 1.875rem; + font-weight: 700; + font-family: Montserrat,sans-serif; + line-height: 1.25; + padding: 1rem; + padding-top: 1rem; + padding-bottom: 0; + padding-left: 1rem; + color: #292B3E; +} + +.c2 { + font-size: 1rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 2; + max-width: 91.666667%; + margin-top: 0.5rem; + margin-bottom: 0.5rem; + padding-left: 1rem; + padding-right: 1rem; + padding-left: 1rem; + color: #292B3E; +} + +
+

+ heading +

+

+ body +

+
+`; + +exports[`it works with image 1`] = ` +.c0 { + border-bottom-style: solid; + border-bottom-width: 4px; + width: 100%; + margin-bottom: 0.5rem; + border-bottom-color: #fafafa; +} + +test +`; diff --git a/src/components/panel/components/panel-body/index.tsx b/src/components/panel/components/panel-body/index.tsx new file mode 100644 index 00000000..867aa8da --- /dev/null +++ b/src/components/panel/components/panel-body/index.tsx @@ -0,0 +1,37 @@ +import * as React from 'react'; +import { PanelProps, PanelPropType } from '../../index'; +import { Image } from '../../../image'; +import { Box } from '../../../box'; +import { Heading } from '../../../heading'; +import { Text } from '../../../text'; +import { + panelBodyStyles, + panelHeadingStyles, + panelImageStyles +} from './styles'; + +export const PanelBody = ({ + image, + heading, + children +}: Pick) => { + return ( + <> + {image && } + + + {heading?.title && ( + + {heading.title} + + )} + {children && {children}} + + + ); +}; + +PanelBody.displayName = 'PanelBody'; diff --git a/src/components/panel/components/panel-body/styles.ts b/src/components/panel/components/panel-body/styles.ts new file mode 100644 index 00000000..6229aecd --- /dev/null +++ b/src/components/panel/components/panel-body/styles.ts @@ -0,0 +1,27 @@ +import { Styles } from '@lapidist/styles'; +import { PanelProps } from '../../index'; + +export const panelBodyStyles = (): Styles => ({ + paddingX: '4', + paddingLeft: '4', + maxWidth: '11/12', + marginY: '2' +}); + +export const panelImageStyles = (): Styles => ({ + borderBottomColor: { group: 'grey', shade: 'lightest' }, + borderBottomStyle: 'solid', + borderBottomWidth: '2', + marginBottom: '2', + width: 'full' +}); + +export const panelHeadingStyles = ({ + image +}: Pick): Styles => ({ + padding: '4', + paddingTop: image ? '2' : '4', + paddingLeft: '4', + paddingBottom: '0', + fontWeight: 700 +}); diff --git a/src/components/panel/components/panel-buttons/PanelButtons.spec.tsx b/src/components/panel/components/panel-buttons/PanelButtons.spec.tsx new file mode 100644 index 00000000..0c572d33 --- /dev/null +++ b/src/components/panel/components/panel-buttons/PanelButtons.spec.tsx @@ -0,0 +1,35 @@ +import * as React from 'react'; +import { render } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import 'jest-styled-components'; + +import { ThemeProvider } from '../../../theme-provider'; +import { PanelButtons } from './index'; + +const setup = (panel: React.ReactElement) => + render({panel}); + +const defaultProps = { + buttons: undefined +}; + +test('it works', () => { + const { container } = setup(); + expect(container.firstChild).toMatchSnapshot(); +}); + +test('it works with buttons', () => { + const { container, getByText, getAllByRole } = setup( + + ); + expect(container.firstChild).toMatchSnapshot(); + expect(getByText('Button 1')).toBeTruthy(); + expect(getByText('Button 2')).toBeTruthy(); + expect(getAllByRole('button').length).toBe(2); +}); diff --git a/src/components/panel/components/panel-buttons/__snapshots__/PanelButtons.spec.tsx.snap b/src/components/panel/components/panel-buttons/__snapshots__/PanelButtons.spec.tsx.snap new file mode 100644 index 00000000..bf03a6c5 --- /dev/null +++ b/src/components/panel/components/panel-buttons/__snapshots__/PanelButtons.spec.tsx.snap @@ -0,0 +1,201 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`it works 1`] = `null`; + +exports[`it works with buttons 1`] = ` +.c0 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + width: 100%; + -webkit-box-pack: end; + -webkit-justify-content: end; + -ms-flex-pack: end; + justify-content: end; + gap: 0.5rem; +} + +.c2 { + border-style: solid; + text-align: center; + display: inline-block; + position: relative; + font-size: 1rem; + font-weight: 500; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + padding-left: 0.75rem; + padding-right: 0.75rem; + padding-top: 0.5rem; + padding-bottom: 0.5rem; + background-color: #17a3a5; + color: white; + border-color: #17a3a5; +} + +.c2:hover { + cursor: pointer; + background-color: #135f61; + color: white; +} + +.c2:hover:disabled { + cursor: not-allowed; + background-color: #135f61; +} + +.c2:disabled { + opacity: 0.7; + background-color: #135f61; + color: white; +} + +.c1 { + border-style: solid; + text-align: center; + display: inline-block; + position: relative; + font-size: 1rem; + font-weight: 500; + font-family: Montserrat,sans-serif; + line-height: 2; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + padding-left: 0.75rem; + padding-right: 0.75rem; + padding-top: 0.5rem; + padding-bottom: 0.5rem; + background-color: #17a3a5; + color: white; + border-color: #17a3a5; +} + +.c1:hover { + cursor: pointer; + background-color: #135f61; + color: white; +} + +.c1:hover:disabled { + cursor: not-allowed; + background-color: #135f61; +} + +.c1:disabled { + opacity: 0.7; + background-color: #135f61; + color: white; +} + +.c3 { + opacity: 1; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c5 { + border-style: solid; + text-align: center; + display: inline-block; + position: relative; + font-size: 1rem; + font-weight: 500; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + padding-left: 0.75rem; + padding-right: 0.75rem; + padding-top: 0.5rem; + padding-bottom: 0.5rem; + background-color: white; + color: #17a3a5; + border-color: #d4d4d4; +} + +.c5:hover { + cursor: pointer; + background-color: #fafafa; + color: #135f61; +} + +.c5:hover:disabled { + cursor: not-allowed; + background-color: #fafafa; +} + +.c5:disabled { + opacity: 0.7; + background-color: #fafafa; + color: #292B3E; +} + +.c4 { + border-style: solid; + text-align: center; + display: inline-block; + position: relative; + font-size: 1rem; + font-weight: 500; + font-family: Montserrat,sans-serif; + line-height: 2; + border-radius: 0.3rem; + border-width: 2px; + box-shadow: 0 2px 3px rgba(0,0,0,0.1); + padding-left: 0.75rem; + padding-right: 0.75rem; + padding-top: 0.5rem; + padding-bottom: 0.5rem; + background-color: white; + color: #17a3a5; + border-color: #d4d4d4; +} + +.c4:hover { + cursor: pointer; + background-color: #fafafa; + color: #135f61; +} + +.c4:hover:disabled { + cursor: not-allowed; + background-color: #fafafa; +} + +.c4:disabled { + opacity: 0.7; + background-color: #fafafa; + color: #292B3E; +} + +
+ + +
+`; diff --git a/src/components/panel/components/panel-buttons/index.tsx b/src/components/panel/components/panel-buttons/index.tsx new file mode 100644 index 00000000..743ac2e2 --- /dev/null +++ b/src/components/panel/components/panel-buttons/index.tsx @@ -0,0 +1,23 @@ +import * as React from 'react'; +import { Box } from '../../../box'; +import { Button } from '../../../button'; +import { PanelProps } from '../../index'; +import { panelButtonsStyles } from './styles'; + +export const PanelButtons: React.FC> = ({ + buttons +}) => { + if (!buttons?.length) return null; + + return ( + + {buttons.map((button) => ( + + ))} + + ); +}; + +PanelButtons.displayName = 'PanelButtons'; diff --git a/src/components/panel/components/panel-buttons/styles.ts b/src/components/panel/components/panel-buttons/styles.ts new file mode 100644 index 00000000..0332e662 --- /dev/null +++ b/src/components/panel/components/panel-buttons/styles.ts @@ -0,0 +1,8 @@ +import { Styles } from '@lapidist/styles'; + +export const panelButtonsStyles = (): Styles => ({ + display: 'flex', + sizeGap: '2', + width: 'full', + justifyContent: 'end' +}); diff --git a/src/components/panel/components/panel-icons/PanelIcons.spec.tsx b/src/components/panel/components/panel-icons/PanelIcons.spec.tsx new file mode 100644 index 00000000..47cfee5e --- /dev/null +++ b/src/components/panel/components/panel-icons/PanelIcons.spec.tsx @@ -0,0 +1,41 @@ +import * as React from 'react'; +import { render } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import 'jest-styled-components'; + +import { ThemeProvider } from '../../../theme-provider'; +import { PanelIcons } from './index'; +import { PanelStatusType } from '../../index'; + +const setup = (panel: React.ReactElement) => + render({panel}); + +const defaultProps = { + status: undefined, + tag: undefined +}; + +test('it works', () => { + const { container } = setup(); + expect(container.firstChild).toMatchSnapshot(); +}); + +test('it works with status', () => { + const statuses: PanelStatusType[] = ['none', 'info', 'warning', 'error']; + + statuses.forEach((status) => { + const { container } = setup(); + expect(container.firstChild).toMatchSnapshot(); + }); +}); + +test('it works with tag', () => { + const { container, getByText } = setup( + + ); + expect(container.firstChild).toMatchSnapshot(); + expect(getByText('v1.0.0')).toBeTruthy(); +}); diff --git a/src/components/panel/components/panel-icons/__snapshots__/PanelIcons.spec.tsx.snap b/src/components/panel/components/panel-icons/__snapshots__/PanelIcons.spec.tsx.snap new file mode 100644 index 00000000..52a1db80 --- /dev/null +++ b/src/components/panel/components/panel-icons/__snapshots__/PanelIcons.spec.tsx.snap @@ -0,0 +1,239 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`it works 1`] = ` +.c0 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +
+`; + +exports[`it works with status 1`] = ` +.c0 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +
+`; + +exports[`it works with status 2`] = ` +.c0 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c1 { + font-size: 1.875rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 0; + border-radius: 9999px; + margin-right: 1rem; + background-color: white; + color: #73748b; +} + +
+

+ +

+
+`; + +exports[`it works with status 3`] = ` +.c0 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c1 { + font-size: 1.875rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 0; + border-radius: 9999px; + margin-right: 1rem; + background-color: white; + color: #ebc764; +} + +
+

+ +

+
+`; + +exports[`it works with status 4`] = ` +.c0 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c1 { + font-size: 1.875rem; + font-weight: 400; + font-family: Montserrat,sans-serif; + line-height: 0; + border-radius: 9999px; + margin-right: 1rem; + background-color: white; + color: #b41e25; +} + +
+

+ +

+
+`; + +exports[`it works with tag 1`] = ` +.c0 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c1 { + -webkit-flex: 1 1 auto; + -ms-flex: 1 1 auto; + flex: 1 1 auto; +} + +.c2 { + border-style: solid; + text-align: center; + font-size: 0.75rem; + font-weight: 500; + font-family: Montserrat,sans-serif; + line-height: 2; + border-radius: 0.6rem; + border-width: 0; + padding-top: 0.25rem; + padding-bottom: 0.25rem; + background-color: #135f61; + color: white; + border-color: #292B3E; +} + +.c3 { + padding-left: 0.5rem; + padding-right: 0.5rem; + padding-top: 0.25rem; + padding-bottom: 0.25rem; +} + +
+
+ + + v1.0.0 + + +
+
+`; diff --git a/src/components/panel/components/panel-icons/index.tsx b/src/components/panel/components/panel-icons/index.tsx new file mode 100644 index 00000000..278e3166 --- /dev/null +++ b/src/components/panel/components/panel-icons/index.tsx @@ -0,0 +1,55 @@ +import * as React from 'react'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { IconProp } from '@fortawesome/fontawesome-svg-core'; +import { + faCircleCheck, + faCircleExclamation, + faCircleInfo, + faComment +} from '@fortawesome/free-solid-svg-icons'; +import { Box } from '../../../box'; +import { Text } from '../../../text'; +import { Tag } from '../../../tag'; +import { PanelProps, PanelStatusType } from '../../index'; +import { panelIconStyles, panelIconsStyles, panelTagStyles } from './styles'; + +export const PanelIcons: React.FC> = ({ + status, + tag +}) => { + const hasStatus = status && status !== 'none'; + const hasTag = tag?.title; + const getIcon = (variant?: PanelStatusType): IconProp => { + switch (variant) { + case 'warning': + case 'error': + return faCircleExclamation; + case 'success': + return faCircleCheck; + case 'info': + return faCircleInfo; + case 'none': + default: + return faComment; + } + }; + + return ( + + {hasStatus && ( + + + + )} + {hasTag && ( + + + {tag.title} + + + )} + + ); +}; + +PanelIcons.displayName = 'PanelIcons'; diff --git a/src/components/panel/components/panel-icons/styles.ts b/src/components/panel/components/panel-icons/styles.ts new file mode 100644 index 00000000..424da526 --- /dev/null +++ b/src/components/panel/components/panel-icons/styles.ts @@ -0,0 +1,40 @@ +import { Styles } from '@lapidist/styles'; +import { PanelProps } from '../../index'; + +export const panelIconsStyles = (): Styles => ({ + display: 'flex', + alignItems: 'center' +}); + +export const panelIconStyles = ({ status }: Pick) => { + const variantStyles = { + none: { + textColor: { shade: 'base', group: 'grey' } + }, + info: { + textColor: { shade: 'base', group: 'grey' } + }, + warning: { + textColor: { shade: 'base', group: 'secondary' } + }, + error: { + textColor: { shade: 'base', group: 'danger' } + }, + success: { + textColor: { shade: 'base', group: 'tertiary' } + } + }; + + return { + marginRight: '4', + fontSize: '7', + borderRadius: 'rounded', + lineHeight: '0', + backgroundColor: { group: 'base', shade: 'light' }, + ...variantStyles[status || 'none'] + }; +}; + +export const panelTagStyles = (): Styles => ({ + flex: '1 1 auto' +}); diff --git a/src/components/panel/index.tsx b/src/components/panel/index.tsx index 2ccfa890..7517068e 100644 --- a/src/components/panel/index.tsx +++ b/src/components/panel/index.tsx @@ -1,23 +1,55 @@ import * as React from 'react'; import { withTheme } from 'styled-components'; import { mergeStyles, Theme } from '@lapidist/styles'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faClose } from '@fortawesome/free-solid-svg-icons'; import { Elevated, ElevationHeight } from '../elevated'; import { BoxProps } from '../box'; import { Spinner } from '../spinner'; -import { Heading, HeadingProps, HeadingPropType } from '../heading'; -import { panelStyles } from './styles'; +import { HeadingProps, HeadingPropType } from '../heading'; +import { TagProps, TagPropType } from '../tag'; +import { Button, ButtonProps, ButtonPropType } from '../button'; +import { + panelStyles, + panelSpinnerStyles, + panelLoadingStyles, + panelCloseButtonStyles +} from './styles'; +import { ImagePropType } from '../image'; +import { PanelActions } from './components/panel-actions'; +import { PanelBody } from './components/panel-body'; export * from './styles'; export type PanelPropType = BoxProps; +export type PanelStatusType = 'none' | 'info' | 'warning' | 'error' | 'success'; + +export type PanelHeadingProp = { + readonly title: string; + readonly props?: Omit; +}; + +export type PanelTagProp = { + readonly title: string; + readonly props?: Omit; +}; + +export type PanelButtonProp = { + readonly title: string; + readonly props?: Omit; +}; + export interface PanelProps { readonly loading?: boolean; - readonly heading?: { - title: string; - props?: HeadingProps & HeadingPropType; - }; + readonly dismissable?: boolean; + readonly onDismiss?: () => void; + readonly status?: PanelStatusType; + readonly heading?: PanelHeadingProp; readonly elevation?: ElevationHeight; + readonly tag?: PanelTagProp; + readonly buttons?: PanelButtonProp[]; + readonly image?: ImagePropType; readonly theme: Theme; } @@ -25,43 +57,58 @@ const BasePanel: React.FC = ({ as = 'div', styles, loading, + dismissable, + onDismiss, + status, heading, elevation = '1', + tag, + buttons, + image, children, ...restProps -}) => - loading ? ( +}) => { + const [dismissed, setDismissed] = React.useState(false); + + const handleDismiss = () => { + setDismissed(!dismissed); + onDismiss && onDismiss(); + }; + + if (dismissed) return null; + + return ( - - - ) : ( - - {heading?.title && ( - + ) : ( + <> + + {children} + + + + )} + {dismissable && ( + )} - {children} ); +}; export const Panel = withTheme(BasePanel); diff --git a/src/components/panel/styles.ts b/src/components/panel/styles.ts index b28ab561..0ef0a150 100644 --- a/src/components/panel/styles.ts +++ b/src/components/panel/styles.ts @@ -1,9 +1,57 @@ import { Styles } from '@lapidist/styles'; +import { PanelProps } from './index'; -export const panelStyles = (): Styles => ({ - borderRadius: '2', - paddingX: '4', - paddingY: '3', - sizeMinHeight: '32', - backgroundColor: { shade: 'light', group: 'base' } +export const panelStyles = ({ status }: PanelProps): Styles => { + const variantStyles = { + none: { + borderColor: { shade: 'transparent', group: 'base' } + }, + info: { + borderColor: { shade: 'base', group: 'grey' } + }, + warning: { + borderColor: { shade: 'base', group: 'secondary' } + }, + error: { + borderColor: { shade: 'base', group: 'danger' } + }, + success: { + borderColor: { shade: 'base', group: 'tertiary' } + } + }; + + return { + borderStyle: 'solid', + borderWidth: '1', + borderRadius: '2', + sizeMinHeight: '32', + backgroundColor: { shade: 'light', group: 'base' }, + ...variantStyles[status || 'none'] + }; +}; + +export const panelSpinnerStyles = (): Styles => ({ sizeWidth: 16 }); + +export const panelCloseButtonStyles = (): Styles => ({ + position: 'absolute', + top: '0', + right: '0', + marginTop: '6', + marginRight: '6' +}); + +export const panelLoadingStyles = ({ loading }: PanelProps): Styles => + loading + ? { + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + paddingLeft: '0' + } + : {}; + +export const panelMessageStyles = () => ({ + display: 'flex', + alignItems: 'center', + fontSize: '2' }); diff --git a/src/components/status-message/StatusMessage.spec.tsx b/src/components/status-message/StatusMessage.spec.tsx deleted file mode 100644 index 280298e9..00000000 --- a/src/components/status-message/StatusMessage.spec.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import * as React from 'react'; -import { render, fireEvent } from '@testing-library/react'; -import '@testing-library/jest-dom'; -import 'jest-styled-components'; - -import { ThemeProvider } from '../theme-provider'; -import { StatusMessage, StatusMessageVariantType } from './index'; - -const setup = (statusMessage: React.ReactElement) => - render({statusMessage}); - -test('it works', () => { - const { container } = setup( - - ); - expect(container.firstChild).toMatchSnapshot(); -}); - -test('it works with different variants', () => { - const variants: StatusMessageVariantType[] = [ - 'info', - 'success', - 'warning', - 'error' - ]; - variants.forEach((variant) => { - const { container } = setup( - - ); - expect(container.firstChild).toMatchSnapshot(); - }); -}); - -test('it renders message', () => { - const { getByText } = setup( - - ); - expect(getByText('I am a status message')).toBeTruthy(); -}); - -test('it renders dismiss button', () => { - const { getByRole } = setup( - - ); - expect(getByRole('button')).toBeTruthy(); -}); - -test('it dismisses when dismiss button clicked', () => { - const { queryByText, getByRole } = setup( - - ); - fireEvent.click(getByRole('button')); - expect(queryByText('I am a status message')).toBeFalsy(); -}); diff --git a/src/components/status-message/StatusMessage.stories.tsx b/src/components/status-message/StatusMessage.stories.tsx deleted file mode 100644 index 1c78e389..00000000 --- a/src/components/status-message/StatusMessage.stories.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import * as React from 'react'; -import { ThemeProvider } from '../theme-provider'; -import { StatusMessage } from './index'; - -export default { - title: 'Components/StatusMessage', - component: StatusMessage, - decorators: [(getStory) => {getStory()}] -}; - -const templateStyles = {}; - -const DefaultTemplate = (args) => ; - -export const Info = DefaultTemplate.bind({}); -Info.args = { - variant: 'info', - message: 'I am a status message', - styles: templateStyles -}; - -export const Warning = DefaultTemplate.bind({}); -Warning.args = { - variant: 'warning', - message: 'I am a status message', - styles: templateStyles -}; - -export const Error = DefaultTemplate.bind({}); -Error.args = { - variant: 'error', - message: 'I am a status message', - styles: templateStyles -}; - -export const Success = DefaultTemplate.bind({}); -Success.args = { - variant: 'success', - message: 'I am a status message', - styles: templateStyles -}; - -export const InfoDismissable = DefaultTemplate.bind({}); -InfoDismissable.args = { - variant: 'info', - dismissable: true, - message: 'I am a status message', - styles: templateStyles -}; - -export const WarningDismissable = DefaultTemplate.bind({}); -WarningDismissable.args = { - variant: 'warning', - dismissable: true, - message: 'I am a status message', - styles: templateStyles -}; - -export const ErrorDismissable = DefaultTemplate.bind({}); -ErrorDismissable.args = { - variant: 'error', - dismissable: true, - message: 'I am a status message', - styles: templateStyles -}; - -export const SuccessDismissable = DefaultTemplate.bind({}); -SuccessDismissable.args = { - variant: 'success', - dismissable: true, - message: 'I am a status message', - styles: templateStyles -}; diff --git a/src/components/status-message/__snapshots__/StatusMessage.spec.tsx.snap b/src/components/status-message/__snapshots__/StatusMessage.spec.tsx.snap deleted file mode 100644 index 91eed345..00000000 --- a/src/components/status-message/__snapshots__/StatusMessage.spec.tsx.snap +++ /dev/null @@ -1,416 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`it works 1`] = ` -.c0 { - border-style: solid; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - border-radius: 0.3rem; - border-width: 1px; - border-left-width: 4px; - box-shadow: 0 2px 3px rgba(0,0,0,0.1); - -webkit-box-pack: justify; - -webkit-justify-content: space-between; - -ms-flex-pack: justify; - justify-content: space-between; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - padding-left: 1rem; - padding-right: 1rem; - padding-top: 0.5rem; - padding-bottom: 0.5rem; - background-color: white; - border-color: #73748b; -} - -.c1 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - font-size: 0.875rem; - font-weight: 400; - font-family: Montserrat,sans-serif; - line-height: 2; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - color: #292B3E; -} - -.c2 { - display: inline; - font-size: 1rem; - font-weight: 400; - font-family: Montserrat,sans-serif; - line-height: 2; - margin-right: 0.75rem; - color: #292B3E; -} - -
-

-

- -

- I am a status message -

-
-`; - -exports[`it works with different variants 1`] = ` -.c0 { - border-style: solid; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - border-radius: 0.3rem; - border-width: 1px; - border-left-width: 4px; - box-shadow: 0 2px 3px rgba(0,0,0,0.1); - -webkit-box-pack: justify; - -webkit-justify-content: space-between; - -ms-flex-pack: justify; - justify-content: space-between; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - padding-left: 1rem; - padding-right: 1rem; - padding-top: 0.5rem; - padding-bottom: 0.5rem; - background-color: white; - border-color: #73748b; -} - -.c1 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - font-size: 0.875rem; - font-weight: 400; - font-family: Montserrat,sans-serif; - line-height: 2; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - color: #292B3E; -} - -.c2 { - display: inline; - font-size: 1rem; - font-weight: 400; - font-family: Montserrat,sans-serif; - line-height: 2; - margin-right: 0.75rem; - color: #292B3E; -} - -
-

-

- -

- I am a status message -

-
-`; - -exports[`it works with different variants 2`] = ` -.c1 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - font-size: 0.875rem; - font-weight: 400; - font-family: Montserrat,sans-serif; - line-height: 2; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - color: #292B3E; -} - -.c0 { - border-style: solid; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - border-radius: 0.3rem; - border-width: 1px; - border-left-width: 4px; - box-shadow: 0 2px 3px rgba(0,0,0,0.1); - -webkit-box-pack: justify; - -webkit-justify-content: space-between; - -ms-flex-pack: justify; - justify-content: space-between; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - padding-left: 1rem; - padding-right: 1rem; - padding-top: 0.5rem; - padding-bottom: 0.5rem; - background-color: white; - border-color: #72af5d; -} - -.c2 { - display: inline; - font-size: 1rem; - font-weight: 400; - font-family: Montserrat,sans-serif; - line-height: 2; - margin-right: 0.75rem; - color: #548230; -} - -
-

-

- -

- I am a status message -

-
-`; - -exports[`it works with different variants 3`] = ` -.c1 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - font-size: 0.875rem; - font-weight: 400; - font-family: Montserrat,sans-serif; - line-height: 2; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - color: #292B3E; -} - -.c0 { - border-style: solid; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - border-radius: 0.3rem; - border-width: 1px; - border-left-width: 4px; - box-shadow: 0 2px 3px rgba(0,0,0,0.1); - -webkit-box-pack: justify; - -webkit-justify-content: space-between; - -ms-flex-pack: justify; - justify-content: space-between; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - padding-left: 1rem; - padding-right: 1rem; - padding-top: 0.5rem; - padding-bottom: 0.5rem; - background-color: white; - border-color: #ebc764; -} - -.c2 { - display: inline; - font-size: 1rem; - font-weight: 400; - font-family: Montserrat,sans-serif; - line-height: 2; - margin-right: 0.75rem; - color: #937032; -} - -
-

-

- -

- I am a status message -

-
-`; - -exports[`it works with different variants 4`] = ` -.c1 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - font-size: 0.875rem; - font-weight: 400; - font-family: Montserrat,sans-serif; - line-height: 2; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - color: #292B3E; -} - -.c0 { - border-style: solid; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - border-radius: 0.3rem; - border-width: 1px; - border-left-width: 4px; - box-shadow: 0 2px 3px rgba(0,0,0,0.1); - -webkit-box-pack: justify; - -webkit-justify-content: space-between; - -ms-flex-pack: justify; - justify-content: space-between; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - padding-left: 1rem; - padding-right: 1rem; - padding-top: 0.5rem; - padding-bottom: 0.5rem; - background-color: white; - border-color: #b41e25; -} - -.c2 { - display: inline; - font-size: 1rem; - font-weight: 400; - font-family: Montserrat,sans-serif; - line-height: 2; - margin-right: 0.75rem; - color: #810000; -} - -
-

-

- -

- I am a status message -

-
-`; diff --git a/src/components/status-message/index.tsx b/src/components/status-message/index.tsx deleted file mode 100644 index e8d35a9c..00000000 --- a/src/components/status-message/index.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import * as React from 'react'; -import { withTheme } from 'styled-components'; -import { mergeStyles, Theme } from '@lapidist/styles'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { - faClose, - faCircleInfo, - faCircleExclamation, - faCircleCheck -} from '@fortawesome/free-solid-svg-icons'; -import { Text } from '../text'; -import { BoxProps } from '../box'; -import { Elevated } from '../elevated'; -import { Button } from '../button'; -import { - statusMessageIconStyles, - statusMessageMessageStyles, - statusMessageStyles -} from './styles'; - -export * from './styles'; - -export type StatusMessagePropType = BoxProps; - -export type StatusMessageVariantType = 'info' | 'warning' | 'error' | 'success'; - -export interface StatusMessageProps { - readonly variant?: StatusMessageVariantType; - readonly message: string; - readonly dismissable?: boolean; - readonly theme: Theme; -} - -const BaseStatusMessage: React.FC = - ({ - as = 'div', - styles, - variant = 'info', - message, - dismissable, - theme, - ...restProps - }) => { - const [dismissed, setDismissed] = React.useState(false); - - const handleDismiss = () => setDismissed(!dismissed); - - const getIcon = (variant?: StatusMessageVariantType) => { - switch (variant) { - case 'warning': - case 'error': - return faCircleExclamation; - case 'success': - return faCircleCheck; - case 'info': - default: - return faCircleInfo; - } - }; - - if (dismissed) return null; - - return ( - - - - - - {message} - - {dismissable && ( - - )} - - ); - }; - -export const StatusMessage = withTheme(BaseStatusMessage); - -StatusMessage.displayName = 'StatusMessage'; diff --git a/src/components/status-message/styles.ts b/src/components/status-message/styles.ts deleted file mode 100644 index f68b65cd..00000000 --- a/src/components/status-message/styles.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { Styles } from '@lapidist/styles'; -import { StatusMessageProps } from './index'; - -export const statusMessageStyles = ({ - variant -}: StatusMessageProps): Styles => { - const baseStyles = { - display: 'flex', - alignItems: 'center', - justifyContent: 'space-between', - borderRadius: '2', - borderLeftWidth: '2', - borderWidth: 'px', - borderStyle: 'solid', - paddingX: '4', - paddingY: '2', - backgroundColor: { shade: 'light', group: 'base' } - }; - - const variantStyles = { - info: { - borderColor: { shade: 'base', group: 'grey' } - }, - warning: { - borderColor: { shade: 'base', group: 'secondary' } - }, - error: { - borderColor: { shade: 'base', group: 'danger' } - }, - success: { - borderColor: { shade: 'base', group: 'tertiary' } - } - }; - - return { - ...baseStyles, - ...variantStyles[variant || 'info'] - }; -}; - -export const statusMessageMessageStyles = () => ({ - display: 'flex', - alignItems: 'center', - fontSize: '2' -}); - -export const statusMessageIconStyles = ({ variant }: StatusMessageProps) => { - const variantStyles = { - info: { - textColor: { shade: 'dark', group: 'grey' } - }, - warning: { - textColor: { shade: 'dark', group: 'secondary' } - }, - error: { - textColor: { shade: 'dark', group: 'danger' } - }, - success: { - textColor: { shade: 'dark', group: 'tertiary' } - } - }; - - return { - ...variantStyles[variant || 'info'], - display: 'inline', - marginRight: '3', - fontSize: '3' - }; -}; diff --git a/src/components/text/Text.spec.tsx b/src/components/text/Text.spec.tsx index 13c547f8..8514f212 100644 --- a/src/components/text/Text.spec.tsx +++ b/src/components/text/Text.spec.tsx @@ -8,7 +8,7 @@ import { ThemeProvider } from '../theme-provider'; const setup = ( props?: TextPropType, - children: React.ReactElement =

Hello world!

+ children: React.ReactElement = <>Hello world! ) => render( diff --git a/src/components/text/__snapshots__/Text.spec.tsx.snap b/src/components/text/__snapshots__/Text.spec.tsx.snap index 71545936..12f6d113 100644 --- a/src/components/text/__snapshots__/Text.spec.tsx.snap +++ b/src/components/text/__snapshots__/Text.spec.tsx.snap @@ -12,9 +12,7 @@ exports[`it works with defaults 1`] = `

-

- Hello world! -

+ Hello world!

`; @@ -31,8 +29,6 @@ exports[`it works with styles 1`] = `

-

- Hello world! -

+ Hello world!

`; diff --git a/src/components/toggle/__snapshots__/Toggle.spec.tsx.snap b/src/components/toggle/__snapshots__/Toggle.spec.tsx.snap index 7418fc63..ec0a1f02 100644 --- a/src/components/toggle/__snapshots__/Toggle.spec.tsx.snap +++ b/src/components/toggle/__snapshots__/Toggle.spec.tsx.snap @@ -11,8 +11,8 @@ exports[`it works 1`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; background-color: #17a3a5; @@ -53,8 +53,8 @@ exports[`it works 1`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; background-color: #17a3a5; @@ -145,11 +145,11 @@ exports[`it works 2`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #17a3a5; border-color: #d4d4d4; border-top-color: transparent; @@ -187,11 +187,11 @@ exports[`it works 2`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #17a3a5; border-color: #d4d4d4; border-top-color: transparent; @@ -267,11 +267,11 @@ exports[`it works 3`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #73748b; border-color: #fafafa; border-top-color: transparent; @@ -309,11 +309,11 @@ exports[`it works 3`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #73748b; border-color: #fafafa; border-top-color: transparent; @@ -389,11 +389,11 @@ exports[`it works 4`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #b41e25; border-color: #810000; border-top-color: transparent; @@ -431,11 +431,11 @@ exports[`it works 4`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #b41e25; border-color: #810000; border-top-color: transparent; @@ -499,8 +499,8 @@ exports[`it works with checked 1`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; background-color: #17a3a5; @@ -541,8 +541,8 @@ exports[`it works with checked 1`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; background-color: #17a3a5; @@ -633,11 +633,11 @@ exports[`it works with checked 2`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #17a3a5; border-color: #d4d4d4; border-top-color: #73748b; @@ -675,11 +675,11 @@ exports[`it works with checked 2`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #17a3a5; border-color: #d4d4d4; border-top-color: #73748b; @@ -755,11 +755,11 @@ exports[`it works with checked 3`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #73748b; border-color: #fafafa; border-top-color: #73748b; @@ -797,11 +797,11 @@ exports[`it works with checked 3`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #73748b; border-color: #fafafa; border-top-color: #73748b; @@ -877,11 +877,11 @@ exports[`it works with checked 4`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #b41e25; border-color: #810000; border-top-color: #73748b; @@ -919,11 +919,11 @@ exports[`it works with checked 4`] = ` border-radius: 9999px; border-width: 2px; box-shadow: 0 2px 3px rgba(0,0,0,0.1); - padding-left: 1rem; - padding-right: 1rem; + padding-left: 0.75rem; + padding-right: 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; - background-color: transparent; + background-color: white; color: #b41e25; border-color: #810000; border-top-color: #73748b;