Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(EditableField): added unit prop to EditableField.Text DHP-1056 #191

Merged
merged 1 commit into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .creevey/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ module.exports = {
browsers: {
chrome: {
browserName: 'chrome',
version: '101.0',
// Define initial viewport size
viewport: { width: 1024, height: 768 },
// Increase parallel sessions
limit: 2,
},
firefox: {
browserName: 'firefox',
version: '99.0',
viewport: { width: 1024, height: 768 },
limit: 2,
},
Expand Down
14 changes: 14 additions & 0 deletions src/components/EditableField/Text/EditableFieldText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand All @@ -57,6 +58,7 @@ const EditableText = forwardRef<
controlsGroup = false,
multiline,
rows = 1,
unit,
}: EditableFieldTextProps,
ref
) {
Expand Down Expand Up @@ -279,6 +281,18 @@ const EditableText = forwardRef<
}}
/>
)}
{unit && (
<label
sx={{
display: "flex",
justifyContent: "center",
alignItems: "center",
color: "text.40",
}}
>
{unit}
</label>
)}
{
{
default: "",
Expand Down
6 changes: 6 additions & 0 deletions src/components/EditableField/Text/Text.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.