Skip to content

Commit

Permalink
fix: add required
Browse files Browse the repository at this point in the history
  • Loading branch information
oasis-cloud committed Nov 21, 2024
1 parent cba87ec commit 41da784
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/packages/formitem/formitem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@
&-label-required {
color: $form-item-required-color;
margin-right: $form-item-required-margin-right;
display: block;
position: absolute;
left: -0.8em;
}
.nut-form-item-labeltxt {
font-size: 12px;
height: 10px;
position: relative;
}
&-body {
flex: 1;
Expand Down
8 changes: 5 additions & 3 deletions src/packages/formitem/formitem.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,14 @@ export class FormItem extends React.Component<

const { starPosition } = this.context.formInstance
const renderStar = (required || requiredInRules) && (
<Text className="nut-form-item-label-required">*</Text>
<Text className="nut-form-item-label-required required">*</Text>
)
const renderLabel = (
<>
{starPosition === 'left' ? renderStar : null}
<Text className="nut-form-item-labeltxt">{label}</Text>
<Text className="nut-form-item-labeltxt">
{starPosition === 'left' ? renderStar : null}
{label}
</Text>
{starPosition === 'right' ? renderStar : null}
</>
)
Expand Down
8 changes: 5 additions & 3 deletions src/packages/formitem/formitem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,14 @@ export class FormItem extends React.Component<

const { starPosition } = this.context.formInstance
const renderStar = (required || requiredInRules) && (
<div className="nut-form-item-label-required">*</div>
<div className="nut-form-item-label-required required">*</div>
)
const renderLabel = (
<>
{starPosition === 'left' ? renderStar : null}
<span className="nut-form-item-labeltxt">{label}</span>
<span className="nut-form-item-labeltxt">
{starPosition === 'left' ? renderStar : null}
{label}
</span>
{starPosition === 'right' ? renderStar : null}
</>
)
Expand Down

0 comments on commit 41da784

Please sign in to comment.