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

Make required asterix align after text #381

Merged
merged 1 commit into from
Apr 5, 2018
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
3 changes: 2 additions & 1 deletion src/components/FormRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Input from './Input';
import Label from './Label';
import RadioInput from './RadioInput';
import Row from './Row';
import Required from './Required';
import StaticInput from './StaticInput';

const typeTranslations = {
Expand Down Expand Up @@ -69,7 +70,7 @@ const FormRow = (props) => {
{label && (
<Label for={id} sm={labelWidth} size={size} className={labelAlignment}>
{label}
{required && label ? <span className="text-danger">&nbsp;*</span> : null}
{required && label ? <Required /> : null}
</Label>
)}
<Col sm={inputContainerWidth}>
Expand Down
7 changes: 7 additions & 0 deletions src/components/Required.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

const Required = () => (
<span className="text-danger pl-1" style={{ position: 'absolute' }}>*</span>
);

export default Required;
5 changes: 2 additions & 3 deletions test/components/FormRow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ describe('<FormRow />', () => {

it('should show a star', () => {
const label = component.find(Label);
const star = label.find('span');
const star = label.find('Required');

assert.equal(star.hasClass('text-danger'), true);
assert.equal(star.text(), ' *');
assert.equal(star.length, 1);
});
});

Expand Down