From f1b0de272ae06fd22c3b251db4115dfcf3b8c423 Mon Sep 17 00:00:00 2001 From: Giuseppe Battistella Date: Thu, 26 May 2022 13:22:36 -0300 Subject: [PATCH] feat(EditableField): added `unit` prop to EditableField.Text DHP-1056 --- .creevey/config.js | 2 ++ .../EditableField/Text/EditableFieldText.tsx | 14 ++++++++++++++ .../EditableField/Text/Text.stories.tsx | 6 ++++++ .../EditableField/Text/With Unit/chrome.png | Bin 0 -> 1190 bytes .../EditableField/Text/With Unit/firefox.png | Bin 0 -> 1682 bytes 5 files changed, 22 insertions(+) create mode 100644 tests/images/Design System/EditableField/Text/With Unit/chrome.png create mode 100644 tests/images/Design System/EditableField/Text/With Unit/firefox.png diff --git a/.creevey/config.js b/.creevey/config.js index b14e3b49..bea3d145 100644 --- a/.creevey/config.js +++ b/.creevey/config.js @@ -7,6 +7,7 @@ module.exports = { browsers: { chrome: { browserName: 'chrome', + version: '101.0', // Define initial viewport size viewport: { width: 1024, height: 768 }, // Increase parallel sessions @@ -14,6 +15,7 @@ module.exports = { }, firefox: { browserName: 'firefox', + version: '99.0', viewport: { width: 1024, height: 768 }, limit: 2, }, diff --git a/src/components/EditableField/Text/EditableFieldText.tsx b/src/components/EditableField/Text/EditableFieldText.tsx index b813bc06..57b5a641 100644 --- a/src/components/EditableField/Text/EditableFieldText.tsx +++ b/src/components/EditableField/Text/EditableFieldText.tsx @@ -37,6 +37,7 @@ export interface EditableFieldTextProps { // When true renders a textarea instead of an input multiline?: boolean rows?: number + unit?: string } const EditableText = forwardRef< @@ -57,6 +58,7 @@ const EditableText = forwardRef< controlsGroup = false, multiline, rows = 1, + unit, }: EditableFieldTextProps, ref ) { @@ -279,6 +281,18 @@ const EditableText = forwardRef< }} /> )} + {unit && ( + + )} { { default: "", diff --git a/src/components/EditableField/Text/Text.stories.tsx b/src/components/EditableField/Text/Text.stories.tsx index 98fb2f50..6e27cc43 100644 --- a/src/components/EditableField/Text/Text.stories.tsx +++ b/src/components/EditableField/Text/Text.stories.tsx @@ -36,6 +36,12 @@ Default.args = { value: "Handle 123", } +export const WithUnit = Template.bind({}) +WithUnit.args = { + value: "123", + unit: "cm", +} + export const Loading = Template.bind({}) Loading.args = { value: "Handle 123", diff --git a/tests/images/Design System/EditableField/Text/With Unit/chrome.png b/tests/images/Design System/EditableField/Text/With Unit/chrome.png new file mode 100644 index 0000000000000000000000000000000000000000..9739c6af75bd54c62c367b8c4c95c977c5a5be6e GIT binary patch literal 1190 zcmbtTeN@_27{)I-65Rb(p6ul+x3TiPHSYsZ+_rqT|Q#v^hmhDilSBc($ge zG+ZEl#g9!>I4y;kL#Mi%(`_n!Bj=XvgZ-}h^L zavc27(L*p83?6?rCKU$rw1OD!Ke&W;fD#fId11!89pIly*=0RJI&OPaqH4o z0_nXesI#^vD3rWcBdm~SxNhdGVwdUiWrO324zsIRbk1Uw4sijEMmq(xRaevgR`Njr zbKzdL0>HyOya7D-Uk*(rm31uEg1#g1N3l4C!C;VG4}XXwlgYzXa6i4lQ15oTk;4N6 zF(y&w&V)&?cdnFp05Rr0y4Uu%eqm1M9~y(n)G%08Ri&Ss;|GM(?53`Cvy#b7hE8)^ zTU!Z4qEIXr-<_40hjF=Fb9au8()S9W*yeD@v|ugXH=E7%TyBR<7ETmp3~wyzHrA$l zu~)X=@$&Y63o5Y>eOF+#p$G&5z1iICgNQ`gUj;g^Q|1+8;1%8UjfJA3BD?k1YamKGhAqXPUNrth zBkvB7ID9Of-I3UM zd1q@4NTKAAe0*USX9c%ZOs(Dq@c)eCzl?CD(j&(72LIr@`9?qvi;qo?5k+NP{Rg-3 BISK#( literal 0 HcmV?d00001 diff --git a/tests/images/Design System/EditableField/Text/With Unit/firefox.png b/tests/images/Design System/EditableField/Text/With Unit/firefox.png new file mode 100644 index 0000000000000000000000000000000000000000..d9f788e370061a5e80cc850c1634c069664cb713 GIT binary patch literal 1682 zcmeAS@N?(olHy`uVBq!ia0y~yV158(t8lOZNzQEnP7Dlek)AG&Ar*0N@1E}NkC$Qp za6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