# .github/workflows/chromatic.yml # name of our action name:"Chromatic Deployment" # the event that will trigger the action on: # Trigger the workflow on push or pull request, # but only for the main branch push: branches: -main # what the action will do jobs: test: # the operating system it will run on runs-on:ubuntu-latest # the list of steps that the action will go through steps: -uses:actions/checkout@v2 -run:cdsrc/marsen.react&&yarn&&yarnbuild&&yarnbuild-storybook -uses:chromaui/action@v1 with: projectToken:${{secrets.CHROMATIC_PROJECT_TOKEN}} token:${{secrets.GITHUB_TOKEN}} storybookBuildDir:storybook-static
// Configures Storybook to log the actions(onArchiveTask and onPinTask) in the UI. exportconst parameters = { actions: { argTypesRegex: '^on[A-Z].*' }, };
// A simple redux store/actions/reducer implementation. // A true app would be more complex and separated into different files. import { createStore } from'redux'; import { TaskItem, TaskState } from'../components/Task';
// The reducer describes how the contents of the store change for each action exportconstreducer = (state: any, action: { id:string; type: TaskState; }) => { switch (action.type) { caseTaskState.Archived: caseTaskState.Pinned: returntaskStateReducer(action.type)(state, action); default: return state; } };
// The initial state of our store when the app loads. // Usually you would fetch this from a server constdefaultTasks:Array<TaskItem> = [ { id: '1', title: 'Something', state: TaskState.Inbox }, { id: '2', title: 'Something more', state: TaskState.Inbox }, { id: '3', title: 'Something else', state: TaskState.Inbox }, { id: '4', title: 'Something again', state: TaskState.Inbox }, ];
// We export the constructed redux store exportdefaultcreateStore(reducer, { tasks: defaultTasks });
// All our reducers simply change the state of a single task. functiontaskStateReducer(taskState: TaskState) { return(state: { tasks: TaskItem[]; }, action: { id: string; }) => { return { ...state, tasks: state.tasks.map(task => task.id === action.id ? { ...task, state: taskState } : task ), }; }; }