Generate a two-word project name (#184)
* add name generator lib * update reducers * make initialState a function * update initialState function
This commit is contained in:
parent
d0f7326588
commit
449e103fc6
3 changed files with 15 additions and 6 deletions
|
@ -32,7 +32,7 @@ const defaultCSS =
|
|||
}
|
||||
`;
|
||||
|
||||
function initialState() {
|
||||
const initialState = () => {
|
||||
const a = objectID().toHexString();
|
||||
const b = objectID().toHexString();
|
||||
const c = objectID().toHexString();
|
||||
|
@ -70,7 +70,7 @@ function initialState() {
|
|||
fileType: 'file',
|
||||
children: []
|
||||
}];
|
||||
}
|
||||
};
|
||||
|
||||
function getAllDescendantIds(state, nodeId) {
|
||||
return state.find(file => file.id === nodeId).children
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
import * as ActionTypes from '../../../constants';
|
||||
import generate from 'project-name-generator';
|
||||
|
||||
const initialState = {
|
||||
name: 'Hello p5.js'
|
||||
const initialState = () => {
|
||||
const generatedString = generate({ words: 2 }).spaced;
|
||||
const generatedName = generatedString.charAt(0).toUpperCase() + generatedString.slice(1);
|
||||
return {
|
||||
name: generatedName
|
||||
};
|
||||
};
|
||||
|
||||
const project = (state = initialState, action) => {
|
||||
const project = (state, action) => {
|
||||
if (state === undefined) {
|
||||
state = initialState(); // eslint-disable-line
|
||||
}
|
||||
switch (action.type) {
|
||||
case ActionTypes.SET_PROJECT_NAME:
|
||||
return Object.assign({}, { ...state }, { name: action.name });
|
||||
|
@ -21,7 +29,7 @@ const project = (state = initialState, action) => {
|
|||
owner: action.owner
|
||||
};
|
||||
case ActionTypes.RESET_PROJECT:
|
||||
return initialState;
|
||||
return initialState();
|
||||
case ActionTypes.SHOW_EDIT_PROJECT_NAME:
|
||||
return Object.assign({}, state, { isEditingName: true });
|
||||
case ActionTypes.HIDE_EDIT_PROJECT_NAME:
|
||||
|
|
|
@ -94,6 +94,7 @@
|
|||
"passport": "^0.3.2",
|
||||
"passport-github": "^1.1.0",
|
||||
"passport-local": "^1.0.0",
|
||||
"project-name-generator": "^2.1.3",
|
||||
"react": "^15.1.0",
|
||||
"react-dom": "^15.1.0",
|
||||
"react-inlinesvg": "^0.4.2",
|
||||
|
|
Loading…
Reference in a new issue