-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2195 from SpareBank1/develop_fix-dom-nesting-date…
…picker a11y datepicker
- Loading branch information
Showing
15 changed files
with
155 additions
and
133 deletions.
There are no files selected for viewing
13 changes: 7 additions & 6 deletions
13
component-overview/examples/datepicker/Datepicker-birthdate.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
import { useState } from 'react'; | ||
import { Datepicker } from '@sb1/ffe-datepicker-react'; | ||
import { InputGroup } from '@sb1/ffe-form-react'; | ||
|
||
() => { | ||
const [date, setDate] = useState(''); | ||
const now = new Date(); | ||
|
||
const maxDate = `${now.getDate()}.${now.getMonth()+1}.${now.getFullYear()}`; | ||
const maxDate = `${now.getDate()}.${now.getMonth() + 1}.${now.getFullYear()}`; | ||
|
||
return ( | ||
<> | ||
<p>Skriv inn et fødselsdato med tosifret årstal og se om det blir tolket riktig.</p> | ||
<InputGroup | ||
label="Fødselsdato" | ||
description="Skriv inn et fødselsdato med tosifret årstal og se om det blir tolket riktig." | ||
> | ||
<Datepicker | ||
inputProps={{ id: 'datepicker-birthday-example' }} | ||
label="Fødelsedato" | ||
locale="nb" | ||
maxDate={maxDate} | ||
onChange={setDate} | ||
value={date} | ||
/> | ||
</> | ||
</InputGroup> | ||
); | ||
}; |
23 changes: 12 additions & 11 deletions
23
component-overview/examples/datepicker/Datepicker-calendarAbove.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import { useState } from 'react'; | ||
import { Datepicker } from '@sb1/ffe-datepicker-react'; | ||
import { InputGroup } from '@sb1/ffe-form-react'; | ||
|
||
() => { | ||
const [date, setDate] = useState('01.01.2016'); | ||
|
||
return ( | ||
<Datepicker | ||
calendarAbove={true} | ||
inputProps={{ id: 'datepicker-example-calendar-above' }} | ||
label="Velg dato" | ||
locale="nb" | ||
maxDate="31.12.2016" | ||
minDate="01.01.2016" | ||
onChange={setDate} | ||
value={date} | ||
/> | ||
<InputGroup label="Velg dato"> | ||
<Datepicker | ||
calendarAbove={true} | ||
locale="nb" | ||
maxDate="31.12.2016" | ||
minDate="01.01.2016" | ||
onChange={setDate} | ||
value={date} | ||
/> | ||
</InputGroup> | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
import { useState } from 'react'; | ||
import { Datepicker } from '@sb1/ffe-datepicker-react'; | ||
import { InputGroup } from '@sb1/ffe-form-react'; | ||
|
||
() => { | ||
const [date, setDate] = useState('01.01.2016'); | ||
|
||
return ( | ||
<Datepicker | ||
inputProps={{ id: 'datepicker-example' }} | ||
label="Velg dato" | ||
locale="en" | ||
maxDate="31.12.2016" | ||
minDate="01.01.2016" | ||
onChange={setDate} | ||
value={date} | ||
/> | ||
<InputGroup label="Pick date"> | ||
<Datepicker | ||
locale="en" | ||
maxDate="31.12.2016" | ||
minDate="01.01.2016" | ||
onChange={setDate} | ||
value={date} | ||
/> | ||
</InputGroup> | ||
); | ||
} | ||
}; |
23 changes: 12 additions & 11 deletions
23
component-overview/examples/datepicker/Datepicker-fullWidth.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import { useState } from 'react'; | ||
import { Datepicker } from '@sb1/ffe-datepicker-react'; | ||
import { InputGroup } from '@sb1/ffe-form-react'; | ||
|
||
() => { | ||
const [date, setDate] = useState('01.01.2016'); | ||
|
||
return ( | ||
<Datepicker | ||
fullWidth={true} | ||
inputProps={{ id: 'datepicker-example-full-width' }} | ||
label="Velg dato" | ||
locale="nb" | ||
maxDate="31.12.2016" | ||
minDate="01.01.2016" | ||
onChange={setDate} | ||
value={date} | ||
/> | ||
<InputGroup label="Velg dato"> | ||
<Datepicker | ||
fullWidth={true} | ||
locale="nb" | ||
maxDate="31.12.2016" | ||
minDate="01.01.2016" | ||
onChange={setDate} | ||
value={date} | ||
/> | ||
</InputGroup> | ||
); | ||
} | ||
}; |
23 changes: 12 additions & 11 deletions
23
component-overview/examples/datepicker/Datepicker-invalid.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import { useState } from 'react'; | ||
import { Datepicker } from '@sb1/ffe-datepicker-react'; | ||
import { InputGroup } from '@sb1/ffe-form-react'; | ||
|
||
() => { | ||
const [date, setDate] = useState('01.01.2016'); | ||
|
||
return ( | ||
<Datepicker | ||
aria-invalid="true" | ||
inputProps={{ id: 'datepicker-example-aria-invalid' }} | ||
label="Velg dato" | ||
locale="nn" | ||
maxDate="31.12.2016" | ||
minDate="01.01.2016" | ||
onChange={setDate} | ||
value={date} | ||
/> | ||
<InputGroup label="Velg dato"> | ||
<Datepicker | ||
aria-invalid="true" | ||
locale="nn" | ||
maxDate="31.12.2016" | ||
minDate="01.01.2016" | ||
onChange={setDate} | ||
value={date} | ||
/> | ||
</InputGroup> | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
import { useState } from 'react'; | ||
import { Datepicker } from '@sb1/ffe-datepicker-react'; | ||
import { InputGroup } from '@sb1/ffe-form-react'; | ||
|
||
() => { | ||
const [date, setDate] = useState('01.01.2016'); | ||
|
||
return ( | ||
<Datepicker | ||
inputProps={{ id: 'datepicker-example' }} | ||
label="Velg dato" | ||
locale="nn" | ||
maxDate="31.12.2016" | ||
minDate="01.01.2016" | ||
onChange={setDate} | ||
value={date} | ||
/> | ||
<InputGroup label="Velg dato"> | ||
<Datepicker | ||
locale="nn" | ||
maxDate="31.12.2016" | ||
minDate="01.01.2016" | ||
onChange={setDate} | ||
value={date} | ||
/> | ||
</InputGroup> | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
import { useState, useRef } from 'react'; | ||
import { useState, useId } from 'react'; | ||
import { Datepicker } from '@sb1/ffe-datepicker-react'; | ||
import { InputGroup } from '@sb1/ffe-form-react'; | ||
|
||
() => { | ||
const [date, setDate] = useState('01.01.2016'); | ||
const innerRef = useRef(date); //Optional ref to the input element | ||
const inputId = useId(); | ||
|
||
return ( | ||
<Datepicker | ||
inputProps={{ id: 'datepicker-example' }} | ||
label="Velg dato" | ||
locale="nb" | ||
maxDate="31.12.2016" | ||
minDate="01.01.2016" | ||
onChange={setDate} | ||
value={date} | ||
innerRef={innerRef} | ||
/> | ||
<InputGroup label="Dato" inputId={inputId}> | ||
<Datepicker | ||
inputProps={{ id: inputId }} | ||
locale="nb" | ||
maxDate="31.12.2016" | ||
minDate="01.01.2016" | ||
onChange={setDate} | ||
value={date} | ||
/> | ||
</InputGroup> | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.