Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6000945
Renamed class for clarification
martijnrusschen Jul 1, 2014
611adea
Renamed classes and did some basic styling
martijnrusschen Jul 1, 2014
0202872
Extracted logic to the sass way with extend
martijnrusschen Jul 1, 2014
5fbba72
Simply reuse components instead of duplicate them
martijnrusschen Jul 1, 2014
4bc9e9d
Added variable
martijnrusschen Jul 1, 2014
53013b1
Adjusted styling of heading
martijnrusschen Jul 1, 2014
9d087f6
Adjusted variable name
martijnrusschen Jul 1, 2014
87e96f4
Fixed width calculation of calendar heading
martijnrusschen Jul 1, 2014
b48da31
Removed floats and going with margins
martijnrusschen Jul 1, 2014
bcc6d4d
Added back and forward icons
martijnrusschen Jul 1, 2014
2848d0f
Removed comment
martijnrusschen Jul 2, 2014
30c63ee
Merge branch 'master' into basic-styling
martijnrusschen Jul 2, 2014
2e1f7a9
Compiled new styles
martijnrusschen Jul 2, 2014
486e9f4
Renamed classes
martijnrusschen Jul 2, 2014
4e45037
Fixed typo
martijnrusschen Jul 2, 2014
859e7ab
Renamed file
martijnrusschen Jul 2, 2014
474ba93
Added author
martijnrusschen Jul 2, 2014
8365892
Forgot to rename the style here as well
martijnrusschen Jul 2, 2014
fe28728
Extracted mixing and variables
martijnrusschen Jul 2, 2014
ec09a7b
Added readme
martijnrusschen Jul 2, 2014
d82c63f
Fixed comments by @lbekkema
martijnrusschen Jul 2, 2014
28a4841
Added triangle
martijnrusschen Jul 2, 2014
00c4ed8
Simplify triangle styling
martijnrusschen Jul 2, 2014
17e4af6
Added Open Sans font
martijnrusschen Jul 2, 2014
14c71f5
Fixed markdown
martijnrusschen Jul 2, 2014
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# React Date Picker

## Installation

- Install Bower `npm install -g bower`
- Install packages `npm install`
- Start a static webserver `python -m SimpleHTTPServer`
- And visit `localhost:8000/example.html` to see the example.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "react-date-picker",
"version": "0.0.0",
"authors": [
"Remon Oldenbeuving <remon@hackerone.com>"
"Remon Oldenbeuving <remon@hackerone.com>",
"Martijn Russchen <martijn@hackerone.com"
],
"description": "A simple and reusable datepicker component for React",
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions example.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<script src="bower_components/moment/moment.js"></script>
<script src="bower_components/react/react-with-addons.js"></script>
<script src="bower_components/react/JSXTransformer.js"></script>
<link rel="stylesheet" type="text/css" href="src/stylesheets/style.css">
<link rel="stylesheet" type="text/css" href="src/stylesheets/style.min.css">
</head>
<body>
<h1>ReactJS DatePicker Example</h1>

<div id="calendar"></div>
<div id="calendar-container"></div>

<script type="text/javascript" src="src/util/date.js"></script>
<script type="text/jsx" src="src/day.jsx"></script>
Expand All @@ -18,7 +18,7 @@ <h1>ReactJS DatePicker Example</h1>

<script type="text/jsx">
/** @jsx React.DOM */
React.renderComponent(<DatePicker />, document.querySelector('#calendar'));
React.renderComponent(<DatePicker />, document.querySelector('#calendar-container'));
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function(grunt) {
style: 'compressed'
},
files: {
'src/stylesheets/style.css' : 'src/stylesheets/datepicker.scss'
'src/stylesheets/style.min.css' : 'src/stylesheets/datepicker.scss'
}
}
},
Expand Down
29 changes: 15 additions & 14 deletions src/calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,30 @@ window.Calendar = React.createClass({
render: function() {
return (
<div className="calendar">
<div className="calendar-triangle"></div>
<div className="calendar-header">
<a className="calendar-month-navigation-left"
<a className="calendar-header-navigation-left"
onClick={this.decreaseMonth}>
&laquo;
<i className="icon-backward"></i>
</a>
<span className="calendar-current-month">
<span className="calendar-header-month">
{this.state.date.format("MMMM YYYY")}
</span>
<a className="calendar-month-navigation-right"
<a className="calendar-header-navigation-right"
onClick={this.increaseMonth}>
&raquo;
<i className="icon-forward"></i>
</a>
</div>
<div className="month">
<div>
<div className="day head">MO</div>
<div className="day head">TU</div>
<div className="day head">WE</div>
<div className="day head">TH</div>
<div className="day head">FR</div>
<div className="day head">SA</div>
<div className="day head">SU</div>
<div className="calendar-header-day">MO</div>
<div className="calendar-header-day">TU</div>
<div className="calendar-header-day">WE</div>
<div className="calendar-header-day">TH</div>
<div className="calendar-header-day">FR</div>
<div className="calendar-header-day">SA</div>
<div className="calendar-header-day">SU</div>
</div>
</div>
<div className="calendar-month">
{this.weeks()}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/day.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ window.Day = React.createClass({

render: function() {
classes = React.addons.classSet({
'day': true,
'calendar-day': true,
'selected': this.props.day.sameDay(this.props.selected),
'this-month': this.props.day.sameMonth(this.props.date),
'today': this.props.day.sameDay(moment())
Expand Down
Binary file added src/fonts/OpenSans-Bold.ttf
Binary file not shown.
Binary file added src/fonts/OpenSans-Regular.ttf
Binary file not shown.
16 changes: 16 additions & 0 deletions src/fonts/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "",
"css_prefix_text": "icon-",
"css_use_suffix": false,
"hinting": true,
"units_per_em": 1000,
"ascent": 850,
"glyphs": [
{
"uid": "ce06b5805120d0c2f8d60cd3f1a4fdb5",
"css": "play",
"code": 59392,
"src": "fontawesome"
}
]
}
Binary file added src/fonts/fontello.woff
Binary file not shown.
105 changes: 70 additions & 35 deletions src/stylesheets/datepicker.scss
Original file line number Diff line number Diff line change
@@ -1,56 +1,91 @@
.month {
border-left: 1px solid black;
border-top: 1px solid black;
display: inline-block;
}
@import 'variables';
@import 'mixins';
@import 'open-sans';
@import 'fontello';

.day {
display: inline-block;
width: 28px;
border-right: 1px solid black;
border-bottom: 1px solid black;
line-height: 28px;
text-align: center;
.calendar {
font-family: 'Open Sans', sans-serif;
font-size: 11px;
color: #ccc;
cursor: pointer;
border: 1px solid $border-color;
border-radius: $border-radius;
display: inline-block;
position: relative;
}

.this-month {
color: black;
.calendar-triangle {
@extend %triangle-arrow-up;
position: absolute;
left: 50px;
}

.selected {
color: blue;
.calendar-header {
text-align: center;
background-color: $background-color;
border-bottom: 1px solid $border-color;
border-top-left-radius: $border-radius;
border-top-right-radius: $border-radius;
padding-top: 5px;
position: relative;
}

.today {
color: red;
.calendar-header-month {
color: black;
font-weight: bold;
font-size: 13px;
}

.calendar-month-navigation-left,
.calendar-month-navigation-right {
width: 28px;
line-height: 28px;
text-align: center;
cursor: pointer;
border-right: 1px solid black;
border-left: 1px solid black;
.calendar-header-navigation-left {
@extend %calendar-navigation;
left: 10px;
}

.calendar-month-navigation-left {
float: left;
.calendar-header-navigation-right {
@extend %calendar-navigation;
right: 10px;
}

.calendar-month-navigation-right {
float: right;
.calendar-header-day {
display: inline-block;
width: $item-size;
line-height: $item-size;
}

.calendar-header {
position: relative;
.calendar-month {
margin: $calendar-margin;
text-align: center;
border-top: 1px solid black;
}

.calendar {
.calendar-day {
display: inline-block;
width: $item-size;
line-height: $item-size;
text-align: center;
margin: 2px;

&.this-month {
color: black;
cursor: pointer;
}

&:hover {
@extend %transparant-rounded-border;
background-color: $background-color;
color: black;
}

&.today {
font-weight: bold;
}

&.selected {
@extend %transparant-rounded-border;
background-color: $selected-color;
color: white;

&:hover {
background-color: darken($selected-color, 5%);
color: white;
}
}
}
41 changes: 41 additions & 0 deletions src/stylesheets/fontello.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// ATTENTION:
// Generate the font using fontello.com, upload fontello-config.json.
// Then replace the font (woff) and manually update this file with the added icons.

@font-face {
font-family: 'fontello';
src: url('../fonts/fontello.woff') format('woff');
font-weight: normal;
font-style: normal;
}

.icon-forward,
.icon-backward {
font-family: "fontello";
font-style: normal;
font-weight: normal;
speak: none;
display: inline-block;
text-decoration: inherit;
width: 1em;
margin-right: .2em;
text-align: center;
font-variant: normal;
text-transform: none;
line-height: 1em;
margin-left: .2em;
}


// Formally icon-play, but renamed for readability
.icon-forward:before { content: '\e800'; }

.icon-backward {
transform:rotate(180deg);
-webkit-transform:rotate(180deg);
-ms-transform:rotate(180deg);

&:before {
content: '\e800';
}
}
39 changes: 39 additions & 0 deletions src/stylesheets/mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
%triangle-arrow-up {
margin-top: -$triangleSize;
margin-left: -$triangleSize;

&, &:before {
box-sizing: content-box;
position: absolute;
border: $triangleSize solid transparent;

height: 0;
width: 1px;
border-top: none;
border-bottom-color: $background-color;
}

&:before {
content: '';
z-index: -1;
border-width: $triangleSize;

top: -1px;
left: -$triangleSize;
border-bottom-color: $border-color;
}
}

%calendar-navigation {
width: $item-size;
line-height: $item-size;
text-align: center;
cursor: pointer;
position: absolute;
top: 5px;
}

%transparant-rounded-border {
border: 1px solid transparant;
border-radius: $border-radius;
}
12 changes: 12 additions & 0 deletions src/stylesheets/open-sans.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans'), local('OpenSans'), url('../fonts/OpenSans-Regular.woff') format('woff');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
src: local('Open Sans Bold'), local('OpenSans-Bold'), url('../fonts/OpenSans-Bold.woff') format('woff');
}
1 change: 0 additions & 1 deletion src/stylesheets/style.css

This file was deleted.

1 change: 1 addition & 0 deletions src/stylesheets/style.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/stylesheets/variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$border-color: #aeaeae;
$background-color: #f0f0f0;
$selected-color: #216ba5;

$border-radius: 4px;
$item-size: 24px;
$calendar-margin: 5px;
$triangleSize: 8px;