Editor Basics (#43)

Add basic editor
This commit is contained in:
Philip Molares 2020-05-29 15:44:45 +02:00 committed by GitHub
parent 557386f78f
commit e2155e735d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
65 changed files with 834 additions and 467 deletions

View file

@ -1,7 +1,7 @@
import { BackendConfigState, SET_BACKEND_CONFIG_ACTION_TYPE, SetBackendConfigAction } from './types'
import { store } from '../../utils/store'
export const setBackendConfig: (state: BackendConfigState) => void = (state: BackendConfigState) => {
export const setBackendConfig = (state: BackendConfigState): void => {
const action: SetBackendConfigAction = {
type: SET_BACKEND_CONFIG_ACTION_TYPE,
payload: {

View file

@ -0,0 +1,14 @@
import {
EditorMode,
SET_EDITOR_CONFIG_MODE_ACTION_TYPE,
SetEditorConfigAction
} from './types'
import { store } from '../../utils/store'
export const setEditorModeConfig = (editorMode: EditorMode): void => {
const action: SetEditorConfigAction = {
type: SET_EDITOR_CONFIG_MODE_ACTION_TYPE,
payload: editorMode
}
store.dispatch(action)
}

View file

@ -0,0 +1,23 @@
import { Reducer } from 'redux'
import {
EditorConfigActions,
EditorConfigState,
EditorMode,
SET_EDITOR_CONFIG_MODE_ACTION_TYPE
} from './types'
export const initialState: EditorConfigState = {
editorMode: EditorMode.PREVIEW
}
export const EditorConfigReducer: Reducer<EditorConfigState, EditorConfigActions> = (state: EditorConfigState = initialState, action: EditorConfigActions) => {
switch (action.type) {
case SET_EDITOR_CONFIG_MODE_ACTION_TYPE:
return {
...state,
editorMode: action.payload
}
default:
return state
}
}

20
src/redux/editor/types.ts Normal file
View file

@ -0,0 +1,20 @@
import { Action } from 'redux'
export const SET_EDITOR_CONFIG_MODE_ACTION_TYPE = 'editor/mode/set'
export interface EditorConfigState {
editorMode: EditorMode;
}
export enum EditorMode {
PREVIEW,
BOTH,
EDITOR,
}
export interface SetEditorConfigAction extends Action {
type: string;
payload: EditorMode;
}
export type EditorConfigActions = SetEditorConfigAction;

View file

@ -1,7 +1,7 @@
import { FrontendConfigState, SET_FRONTEND_CONFIG_ACTION_TYPE, SetFrontendConfigAction } from './types'
import { store } from '../../utils/store'
export const setFrontendConfig: (state: FrontendConfigState) => void = (state: FrontendConfigState) => {
export const setFrontendConfig = (state: FrontendConfigState): void => {
const action: SetFrontendConfigAction = {
type: SET_FRONTEND_CONFIG_ACTION_TYPE,
payload: {

View file

@ -1,23 +1,23 @@
import { combineReducers, Reducer } from 'redux'
import { UserState } from './user/types'
import { UserReducer } from './user/reducers'
import { ModalShowReducer } from './modal/reducers'
import { ModalShowState } from './modal/types'
import { BackendConfigState } from './backend-config/types'
import { FrontendConfigState } from './frontend-config/types'
import { BackendConfigReducer } from './backend-config/reducers'
import { FrontendConfigReducer } from './frontend-config/reducers'
import { EditorConfigState } from './editor/types'
import { EditorConfigReducer } from './editor/reducers'
export interface ApplicationState {
user: UserState;
modalShow: ModalShowState;
backendConfig: BackendConfigState;
frontendConfig: FrontendConfigState;
editorConfig: EditorConfigState;
}
export const allReducers: Reducer<ApplicationState> = combineReducers<ApplicationState>({
user: UserReducer,
modalShow: ModalShowReducer,
backendConfig: BackendConfigReducer,
frontendConfig: FrontendConfigReducer
frontendConfig: FrontendConfigReducer,
editorConfig: EditorConfigReducer
})

View file

@ -1,7 +0,0 @@
import { ActionCreator } from 'redux'
import { SET_HISTORY_DELETE_MODAL_SHOW_ACTION_TYPE, SetHistoryDeleteModalShowAction } from './types'
export const setSignInModalShow: ActionCreator<SetHistoryDeleteModalShowAction> = (historyDelete: boolean) => ({
type: SET_HISTORY_DELETE_MODAL_SHOW_ACTION_TYPE,
payload: historyDelete
})

View file

@ -1,18 +0,0 @@
import { Reducer } from 'redux'
import { ModalShowActions, ModalShowState, SET_HISTORY_DELETE_MODAL_SHOW_ACTION_TYPE } from './types'
export const initialState: ModalShowState = {
historyDelete: false
}
export const ModalShowReducer: Reducer<ModalShowState, ModalShowActions> = (state: ModalShowState = initialState, action: ModalShowActions) => {
switch (action.type) {
case SET_HISTORY_DELETE_MODAL_SHOW_ACTION_TYPE:
return {
...state,
historyDelete: action.payload
}
default:
return state
}
}

View file

@ -1,14 +0,0 @@
import { Action } from 'redux'
export const SET_HISTORY_DELETE_MODAL_SHOW_ACTION_TYPE = 'modal/history-delete/set'
export interface ModalShowState {
historyDelete: boolean
}
export interface SetHistoryDeleteModalShowAction extends Action {
type: string;
payload: boolean;
}
export type ModalShowActions = SetHistoryDeleteModalShowAction;