From 46040f1a77e9a14ef4690be572f177c9cc2072a3 Mon Sep 17 00:00:00 2001 From: Julia Friesel Date: Thu, 28 Jun 2018 10:58:56 +0200 Subject: [PATCH 1/2] Create components and lib folder --- app.js | 8 ++++---- bleeding.js => components/bleeding.js | 6 +++--- calendar.js => components/calendar.js | 4 ++-- components/{ => chart}/chart.js | 4 ++-- components/{ => chart}/config.js | 0 components/{ => chart}/styles.js | 0 cycle-day-overview.js => components/cycle-day-overview.js | 8 ++++---- cycle-day.js => components/cycle-day.js | 6 +++--- home.js => components/home.js | 6 +++--- temperature.js => components/temperature.js | 4 ++-- get-cycle-day-number.js => lib/get-cycle-day-number.js | 2 +- test/get-cycle-day.spec.js | 2 +- 12 files changed, 25 insertions(+), 25 deletions(-) rename bleeding.js => components/bleeding.js (96%) rename calendar.js => components/calendar.js (97%) rename components/{ => chart}/chart.js (98%) rename components/{ => chart}/config.js (100%) rename components/{ => chart}/styles.js (100%) rename cycle-day-overview.js => components/cycle-day-overview.js (93%) rename cycle-day.js => components/cycle-day.js (91%) rename home.js => components/home.js (96%) rename temperature.js => components/temperature.js (96%) rename get-cycle-day-number.js => lib/get-cycle-day-number.js (95%) diff --git a/app.js b/app.js index 92f7e57..7977ed4 100644 --- a/app.js +++ b/app.js @@ -1,9 +1,9 @@ import { createStackNavigator } from 'react-navigation' -import Home from './home' +import Home from './components/home' -import Calendar from './calendar' -import CycleDay from './cycle-day' -import Chart from './components/chart' +import Calendar from './components/calendar' +import CycleDay from './components/cycle-day' +import Chart from './components/chart/chart' // this is until react native fixes this bug, see https://github.com/facebook/react-native/issues/18868#issuecomment-382671739 import { YellowBox } from 'react-native' diff --git a/bleeding.js b/components/bleeding.js similarity index 96% rename from bleeding.js rename to components/bleeding.js index fcbcb50..69efb87 100644 --- a/bleeding.js +++ b/components/bleeding.js @@ -6,9 +6,9 @@ import { Switch } from 'react-native' import RadioForm from 'react-native-simple-radio-button' -import styles from './styles' -import { saveBleeding } from './db' -import { bleeding as labels } from './labels' +import styles from '../styles' +import { saveBleeding } from '../db' +import { bleeding as labels } from '../labels' export default class Bleeding extends Component { constructor(props) { diff --git a/calendar.js b/components/calendar.js similarity index 97% rename from calendar.js rename to components/calendar.js index 0a58513..70cc6ac 100644 --- a/calendar.js +++ b/components/calendar.js @@ -1,8 +1,8 @@ import React, { Component } from 'react' import { View } from 'react-native' import { Calendar } from 'react-native-calendars' -import * as styles from './styles' -import { getOrCreateCycleDay, bleedingDaysSortedByDate } from './db' +import * as styles from '../styles' +import { getOrCreateCycleDay, bleedingDaysSortedByDate } from '../db' export default class CalendarView extends Component { constructor(props) { diff --git a/components/chart.js b/components/chart/chart.js similarity index 98% rename from components/chart.js rename to components/chart/chart.js index b0a6711..2c70ed1 100644 --- a/components/chart.js +++ b/components/chart/chart.js @@ -10,8 +10,8 @@ import Svg,{ Path } from 'react-native-svg' import { LocalDate } from 'js-joda' -import { getCycleDay, getOrCreateCycleDay, cycleDaysSortedByDate } from '../db' -import getCycleDayNumberModule from '../get-cycle-day-number' +import { getCycleDay, getOrCreateCycleDay, cycleDaysSortedByDate } from '../../db' +import getCycleDayNumberModule from '../../lib/get-cycle-day-number' import styles from './styles' import config from './config' diff --git a/components/config.js b/components/chart/config.js similarity index 100% rename from components/config.js rename to components/chart/config.js diff --git a/components/styles.js b/components/chart/styles.js similarity index 100% rename from components/styles.js rename to components/chart/styles.js diff --git a/cycle-day-overview.js b/components/cycle-day-overview.js similarity index 93% rename from cycle-day-overview.js rename to components/cycle-day-overview.js index b5c5370..77b3bf4 100644 --- a/cycle-day-overview.js +++ b/components/cycle-day-overview.js @@ -4,10 +4,10 @@ import { Button, Text } from 'react-native' -import styles from './styles' -import { bleeding as labels} from './labels' -import cycleDayModule from './get-cycle-day-number' -import { bleedingDaysSortedByDate } from './db' +import styles from '../styles' +import { bleeding as labels} from '../labels' +import cycleDayModule from '../lib/get-cycle-day-number' +import { bleedingDaysSortedByDate } from '../db' const getCycleDayNumber = cycleDayModule() diff --git a/cycle-day.js b/components/cycle-day.js similarity index 91% rename from cycle-day.js rename to components/cycle-day.js index def2369..7b7b73f 100644 --- a/cycle-day.js +++ b/components/cycle-day.js @@ -3,12 +3,12 @@ import { View, Text } from 'react-native' -import cycleDayModule from './get-cycle-day-number' +import cycleDayModule from '../lib/get-cycle-day-number' import DayView from './cycle-day-overview' import BleedingEditView from './bleeding' import TemperatureEditView from './temperature' -import { formatDateForViewHeader } from './format' -import styles from './styles' +import { formatDateForViewHeader } from '../format' +import styles from '../styles' const getCycleDayNumber = cycleDayModule() diff --git a/home.js b/components/home.js similarity index 96% rename from home.js rename to components/home.js index 48c7948..5b39620 100644 --- a/home.js +++ b/components/home.js @@ -5,9 +5,9 @@ import { Text } from 'react-native' import { LocalDate } from 'js-joda' -import styles from './styles' -import cycleDayModule from './get-cycle-day-number' -import { getOrCreateCycleDay, bleedingDaysSortedByDate, deleteAll } from './db' +import styles from '../styles' +import cycleDayModule from '../lib/get-cycle-day-number' +import { getOrCreateCycleDay, bleedingDaysSortedByDate, deleteAll } from '../db' const getCycleDayNumber = cycleDayModule() diff --git a/temperature.js b/components/temperature.js similarity index 96% rename from temperature.js rename to components/temperature.js index ea158a1..ace6aa9 100644 --- a/temperature.js +++ b/components/temperature.js @@ -7,8 +7,8 @@ import { Switch } from 'react-native' -import { saveTemperature, getPreviousTemperature } from './db' -import styles from './styles' +import { saveTemperature, getPreviousTemperature } from '../db' +import styles from '../styles' export default class Temp extends Component { constructor(props) { diff --git a/get-cycle-day-number.js b/lib/get-cycle-day-number.js similarity index 95% rename from get-cycle-day-number.js rename to lib/get-cycle-day-number.js index 90646e4..d1b056a 100644 --- a/get-cycle-day-number.js +++ b/lib/get-cycle-day-number.js @@ -6,7 +6,7 @@ export default function config(opts = {}) { let bleedingDaysSortedByDate if (!opts.bleedingDaysSortedByDate) { // we only want to require (and run) the db module when not running the tests - bleedingDaysSortedByDate = require('./db').bleedingDaysSortedByDate + bleedingDaysSortedByDate = require('../db').bleedingDaysSortedByDate } else { bleedingDaysSortedByDate = opts.bleedingDaysSortedByDate } diff --git a/test/get-cycle-day.spec.js b/test/get-cycle-day.spec.js index 222d62e..8aaaddd 100644 --- a/test/get-cycle-day.spec.js +++ b/test/get-cycle-day.spec.js @@ -4,7 +4,7 @@ import dirtyChai from 'dirty-chai' const expect = chai.expect chai.use(dirtyChai) -import getCycleDayNumberModule from '../get-cycle-day-number' +import getCycleDayNumberModule from '../lib/get-cycle-day-number' describe('getCycleDay', () => { it('works for a simple example', function () { From b5af3f7c131c7af0d1df994b53002e500a524d1e Mon Sep 17 00:00:00 2001 From: Julia Friesel Date: Thu, 28 Jun 2018 11:34:55 +0200 Subject: [PATCH 2/2] Make directories for styles and labels --- components/bleeding.js | 4 ++-- components/calendar.js | 2 +- components/cycle-day-overview.js | 4 ++-- components/cycle-day.js | 4 ++-- components/home.js | 2 +- components/temperature.js | 2 +- format.js => labels/format.js | 0 labels.js => labels/labels.js | 0 styles.js => styles/index.js | 0 9 files changed, 9 insertions(+), 9 deletions(-) rename format.js => labels/format.js (100%) rename labels.js => labels/labels.js (100%) rename styles.js => styles/index.js (100%) diff --git a/components/bleeding.js b/components/bleeding.js index 69efb87..0472c3c 100644 --- a/components/bleeding.js +++ b/components/bleeding.js @@ -6,9 +6,9 @@ import { Switch } from 'react-native' import RadioForm from 'react-native-simple-radio-button' -import styles from '../styles' +import styles from '../styles/index' import { saveBleeding } from '../db' -import { bleeding as labels } from '../labels' +import { bleeding as labels } from '../labels/labels' export default class Bleeding extends Component { constructor(props) { diff --git a/components/calendar.js b/components/calendar.js index 70cc6ac..4989d7f 100644 --- a/components/calendar.js +++ b/components/calendar.js @@ -1,7 +1,7 @@ import React, { Component } from 'react' import { View } from 'react-native' import { Calendar } from 'react-native-calendars' -import * as styles from '../styles' +import * as styles from '../styles/index' import { getOrCreateCycleDay, bleedingDaysSortedByDate } from '../db' export default class CalendarView extends Component { diff --git a/components/cycle-day-overview.js b/components/cycle-day-overview.js index 77b3bf4..cc780da 100644 --- a/components/cycle-day-overview.js +++ b/components/cycle-day-overview.js @@ -4,8 +4,8 @@ import { Button, Text } from 'react-native' -import styles from '../styles' -import { bleeding as labels} from '../labels' +import styles from '../styles/index' +import { bleeding as labels} from '../labels/labels' import cycleDayModule from '../lib/get-cycle-day-number' import { bleedingDaysSortedByDate } from '../db' diff --git a/components/cycle-day.js b/components/cycle-day.js index 7b7b73f..7d46dea 100644 --- a/components/cycle-day.js +++ b/components/cycle-day.js @@ -7,8 +7,8 @@ import cycleDayModule from '../lib/get-cycle-day-number' import DayView from './cycle-day-overview' import BleedingEditView from './bleeding' import TemperatureEditView from './temperature' -import { formatDateForViewHeader } from '../format' -import styles from '../styles' +import { formatDateForViewHeader } from '../labels/format' +import styles from '../styles/index' const getCycleDayNumber = cycleDayModule() diff --git a/components/home.js b/components/home.js index 5b39620..60327e3 100644 --- a/components/home.js +++ b/components/home.js @@ -5,7 +5,7 @@ import { Text } from 'react-native' import { LocalDate } from 'js-joda' -import styles from '../styles' +import styles from '../styles/index' import cycleDayModule from '../lib/get-cycle-day-number' import { getOrCreateCycleDay, bleedingDaysSortedByDate, deleteAll } from '../db' diff --git a/components/temperature.js b/components/temperature.js index ace6aa9..c6fccfc 100644 --- a/components/temperature.js +++ b/components/temperature.js @@ -8,7 +8,7 @@ import { } from 'react-native' import { saveTemperature, getPreviousTemperature } from '../db' -import styles from '../styles' +import styles from '../styles/index' export default class Temp extends Component { constructor(props) { diff --git a/format.js b/labels/format.js similarity index 100% rename from format.js rename to labels/format.js diff --git a/labels.js b/labels/labels.js similarity index 100% rename from labels.js rename to labels/labels.js diff --git a/styles.js b/styles/index.js similarity index 100% rename from styles.js rename to styles/index.js