-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23ec465
commit 2bb587a
Showing
40 changed files
with
2,998 additions
and
15 deletions.
There are no files selected for viewing
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
24 changes: 24 additions & 0 deletions
24
docs/app/Examples/addons/Datetime/Content/DatetimeExampleFormatters.js
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react' | ||
import { Datetime } from 'semantic-ui-react' | ||
|
||
// IE or standard language | ||
const locale = navigator.userLanguage || navigator.language | ||
|
||
// Locale formatted date | ||
const dateFormatter = date => date.toLocaleDateString(locale) | ||
|
||
// Locale formatted 12-hour time with seconds removed | ||
const timeFormatter = date => { | ||
return date.toLocaleTimeString(locale, { hour12: true }).replace(/:\d+ /, ' ') | ||
} | ||
|
||
const DatetimeExampleFormatters = () => ( | ||
<Datetime | ||
time | ||
defaultValue={new Date()} | ||
dateFormatter={dateFormatter} | ||
timeFormatter={timeFormatter} | ||
/> | ||
) | ||
|
||
export default DatetimeExampleFormatters |
24 changes: 24 additions & 0 deletions
24
docs/app/Examples/addons/Datetime/Content/Time24HourExample.js
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react' | ||
import { Datetime } from 'semantic-ui-react' | ||
|
||
const Time24HourExample = () => ( | ||
<Datetime | ||
time | ||
icon='time' | ||
date={false} | ||
defaultValue={new Date()} | ||
onChange={(e, {value}) => { | ||
console.log("Time selected: ", value) | ||
}} | ||
hourFormatter={(date) => { | ||
const options = { hour12: false } | ||
return date.toLocaleTimeString('en-US', options).substr(0, 5) | ||
}} | ||
timeFormatter={(date) => { | ||
const options = { hour12: false } | ||
return date.toLocaleTimeString('en-US', options).substr(0, 5) | ||
}} | ||
/> | ||
) | ||
|
||
export default Time24HourExample |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react' | ||
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample' | ||
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection' | ||
|
||
const DatetimeContentExamples = () => ( | ||
<ExampleSection title='Content'> | ||
<ComponentExample | ||
title='Using custom Date and Time formatters' | ||
description='A date time component can use custom date and time formatting functions.' | ||
examplePath='modules/Datetime/Content/DatetimeExampleFormatters' | ||
/> | ||
<ComponentExample | ||
title='Time only with forced 24H format' | ||
description='A full Time selector, where the time display is set to US locale but forced into a 24 hour clock' | ||
examplePath='modules/Datetime/Content/Time24HourExample' | ||
/> | ||
</ExampleSection> | ||
) | ||
|
||
export default DatetimeContentExamples |
8 changes: 8 additions & 0 deletions
8
docs/app/Examples/addons/Datetime/States/DatetimeExampleDisabled.js
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react' | ||
import { Datetime } from 'semantic-ui-react' | ||
|
||
const DatetimeExampleDisabled = () => ( | ||
<Datetime time={false} placeholder='Disabled Date' disabled /> | ||
) | ||
|
||
export default DatetimeExampleDisabled |
29 changes: 29 additions & 0 deletions
29
docs/app/Examples/addons/Datetime/States/DatetimeExampleDisabledDays.js
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react' | ||
import { Datetime } from 'semantic-ui-react' | ||
|
||
function yesterday() { | ||
const _date = new Date() | ||
_date.setDate(_date.getDate() - 1) | ||
return _date | ||
} | ||
|
||
function tomorrow() { | ||
const _date = new Date() | ||
_date.setDate(_date.getDate() + 1) | ||
return _date | ||
} | ||
|
||
const disabledDates = [ | ||
yesterday(), | ||
new Date(), | ||
tomorrow(), | ||
] | ||
const DatetimeExampleDisabledDays = () => ( | ||
<Datetime | ||
time={false} | ||
placeholder='Disabled days' | ||
disabledDates={disabledDates} | ||
/> | ||
) | ||
|
||
export default DatetimeExampleDisabledDays |
8 changes: 8 additions & 0 deletions
8
docs/app/Examples/addons/Datetime/States/DatetimeExampleError.js
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react' | ||
import { Datetime } from 'semantic-ui-react' | ||
|
||
const DatetimeExampleError = () => ( | ||
<Datetime time={false} placeholder='Select Date' error /> | ||
) | ||
|
||
export default DatetimeExampleError |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react' | ||
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample' | ||
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection' | ||
|
||
const DatetimeStatesExamples = () => ( | ||
<ExampleSection title='States'> | ||
<ComponentExample | ||
title='Calendar with disabled days' | ||
description={[ | ||
'A calendar can specify a set of disabled dates.', | ||
'This example has today, yesterday and tomorrow disabled.', | ||
].join(' ')} | ||
examplePath='modules/Datetime/States/DatetimeExampleDisabledDays' | ||
/> | ||
<ComponentExample | ||
title='Error' | ||
description='A calendar can show an error state' | ||
examplePath='modules/Datetime/States/DatetimeExampleError' | ||
/> | ||
<ComponentExample | ||
title='Disabled' | ||
description='A calendar can be disabled' | ||
examplePath='modules/Datetime/States/DatetimeExampleDisabled' | ||
/> | ||
</ExampleSection> | ||
) | ||
|
||
export default DatetimeStatesExamples |
16 changes: 16 additions & 0 deletions
16
docs/app/Examples/addons/Datetime/Types/DateRangeExample.js
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react' | ||
import { Datetime } from 'semantic-ui-react' | ||
|
||
const DateRangeExample = () => ( | ||
<Datetime.Range | ||
defaultValue={[]} | ||
dateHandler='native' | ||
name='date_range' | ||
defaultValue={[new Date('2017-02-28'), new Date('2017-03-10')]} | ||
onChange={(e, {rangeId, name, value}) => { | ||
console.log("Date selected: ", name, rangeId, value) | ||
}} | ||
/> | ||
) | ||
|
||
export default DateRangeExample |
12 changes: 12 additions & 0 deletions
12
docs/app/Examples/addons/Datetime/Types/DatetimeExampleDateOnly.js
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react' | ||
import { Datetime } from 'semantic-ui-react' | ||
|
||
const DatetimeExampleDateOnly = () => ( | ||
<Datetime | ||
time={false} | ||
defaultValue={new Date('2017-04-24')} | ||
placeholder='Select Date' | ||
/> | ||
) | ||
|
||
export default DatetimeExampleDateOnly |
15 changes: 15 additions & 0 deletions
15
docs/app/Examples/addons/Datetime/Types/DatetimeExampleFirstWeekDay.js
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react' | ||
import { Datetime } from 'semantic-ui-react' | ||
|
||
const DatetimeExampleStartSunday = () => ( | ||
<div className='ui two column grid'> | ||
<div className='column'> | ||
<Datetime time={false} placeholder='Week starts Sunday' firstDayOfWeek={0} /> | ||
</div> | ||
<div className='column'> | ||
<Datetime time={false} placeholder='Week starts Monday' /> | ||
</div> | ||
</div> | ||
) | ||
|
||
export default DatetimeExampleStartSunday |
Oops, something went wrong.