Commit 64e9abb6cd8d8e8be200248e9a8eeabe10f3dfe2
extract month name / title responsibilities from marama
mixmix committed on 8/20/2018, 7:51:35 AMParent: 6a63ca3977febbdc5b016c8119cefe3329f0a1a2
Files changed
README.md | changed |
index.js | changed |
styles/index.mcss | changed |
README.md | ||
---|---|---|
@@ -38,9 +38,8 @@ | ||
38 | 38 … | { |
39 | 39 … | month, // month number (by common defn, e.g. 4 is April) |
40 | 40 … | events // (optional) an Array of form: [{ date: Date, data: { ... } }] |
41 | 41 … | year, // (optional) defaults to current year |
42 | - monthNames, // (optional) an Array of month names | |
43 | 42 … | range, // (optional) an Object of form { gte: Date, lt: Date } to highlight |
44 | 43 … | setRange, // (optional) a callback which receives a range on clicks { gte, lt } |
45 | 44 … | styles, // (optional) Object, _see below_ |
46 | 45 … | today // (optional) a Date which can be used to over-ride the definition of today |
index.js | ||
---|---|---|
@@ -2,9 +2,8 @@ | ||
2 | 2 … | const DayTile = require('./day-tile') |
3 | 3 … | const DayLabel = require('./day-label') |
4 | 4 … | const getDay = require('./lib/get-day') |
5 | 5 … | |
6 | -const MONTH_NAMES = [ 'Ja', 'Fe', 'Ma', 'Ap', 'Ma', 'Ju', 'Ju', 'Au', 'Se', 'Oc', 'No', 'De' ] | |
7 | 6 … | const DAYS = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ] |
8 | 7 … | const DEFAULT_FORMAT = 'rows' |
9 | 8 … | |
10 | 9 … | module.exports = function Marama (opts = {}) { |
@@ -12,9 +11,8 @@ | ||
12 | 11 … | const { |
13 | 12 … | events = [], |
14 | 13 … | month = day.getMonth() + 1, // month number (common defn) |
15 | 14 … | year = day.getFullYear(), |
16 | - monthNames = MONTH_NAMES, | |
17 | 15 … | range, |
18 | 16 … | setRange = () => {}, |
19 | 17 … | styles = {}, |
20 | 18 … | today = day |
@@ -37,17 +35,9 @@ | ||
37 | 35 … | range, |
38 | 36 … | setRange |
39 | 37 … | } |
40 | 38 … | |
41 | - const setMonthRange = (ev) => { | |
42 | - setRange({ | |
43 | - gte: new Date(year, monthIndex, 1), | |
44 | - lt: new Date(year, monthIndex + 1, 1) | |
45 | - }) | |
46 | - } | |
47 | - | |
48 | 39 … | return h('Marama', [ |
49 | - // h('div.month-name', { 'ev-click': setMonthRange }, monthNames[monthIndex]), | |
50 | 40 … | h('div.days', { style: getStyles(styles) }, [ |
51 | 41 … | DAYS.map((day, i) => DayLabel(day, i, dayOpts.weekFormat)), |
52 | 42 … | days.map(day => { |
53 | 43 … | dayOpts.day = day // note we're mutating this object (might save memory?) |
Built with git-ssb-web