Skip to content

Commit 0e4f89f

Browse files
committed
feat(form): enable adding rich text as description
in limel-form, we can add a `description` as a prop to form items. This used to returns a `<p>` element in the DOM. In this commit, instead of a normal paragraph, we return a `limel-markdown` component. This enables consumers to use rich text when they write a `description` in their forms.
1 parent ba93930 commit 0e4f89f

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

src/components/form/examples/nested-schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const schema: FormSchema<NestedFormData> = {
2727
address: {
2828
type: 'object',
2929
title: 'Location',
30-
description: 'Please enter your location',
30+
description: 'Please enter your **current** location',
3131
properties: {
3232
city: {
3333
type: 'string',

src/components/form/form.scss

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,9 @@ h1 {
211211
font-weight: 500;
212212
}
213213

214-
p {
215-
margin-top: 0;
216-
margin-bottom: 0.75rem;
217-
font-size: var(--limel-theme-default-font-size);
214+
limel-markdown {
215+
display: block;
216+
margin-bottom: 0.5rem;
218217
}
219218

220219
.form-group {
@@ -226,8 +225,7 @@ p {
226225
left: calc(var(--form-column-gap, 1rem) * -0.5);
227226
}
228227

229-
h1,
230-
p {
228+
h1 {
231229
color: rgb(var(--contrast-1400), 0.8);
232230
}
233231

src/components/form/row/row.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ export class Row extends React.Component<RowProps> {
4949

5050
private renderDescription() {
5151
if (this.schema?.description) {
52-
return React.createElement(
53-
'p',
54-
{ className: 'description' },
55-
this.schema.description
56-
);
52+
return React.createElement('limel-markdown', {
53+
class: 'description',
54+
value: this.schema.description,
55+
});
5756
}
5857
}
5958

src/components/form/templates/common.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ export function renderDescription(description: string) {
2929
return;
3030
}
3131

32-
return React.createElement(
33-
'p',
34-
{ className: 'mdc-typography mdc-typography--body1' },
35-
description
36-
);
32+
return React.createElement('limel-markdown', {
33+
value: description,
34+
});
3735
}
3836

3937
/**

0 commit comments

Comments
 (0)