Download wp-calypso/client/state/ui/layout-focus/reducer.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/ui/layout-focus/reducer.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/ui/layout-focus/reducer.js
-
curl -L -o reducer.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/ui/layout-focus/reducer.js
1.06 kB
| import { | |
| LAYOUT_FOCUS_SET, | |
| LAYOUT_NEXT_FOCUS_ACTIVATE, | |
| LAYOUT_NEXT_FOCUS_SET, | |
| } from 'calypso/state/action-types'; | |
| const initialState = { current: 'content', next: null }; | |
| export default function layoutFocus( state = initialState, action ) { | |
| switch ( action.type ) { | |
| case LAYOUT_FOCUS_SET: | |
| if ( action.area === state.current ) { | |
| return state; | |
| } | |
| return Object.assign( {}, state, { current: action.area } ); | |
| case LAYOUT_NEXT_FOCUS_SET: | |
| if ( action.area === state.next ) { | |
| return state; | |
| } | |
| return Object.assign( {}, state, { next: action.area } ); | |
| case LAYOUT_NEXT_FOCUS_ACTIVATE: { | |
| // If we don't have a change queued, set it to `content`. This avoids | |
| // having to set the focus to content on all navigation links because it | |
| // becomes the default after focus has shifted. | |
| let next = state.next; | |
| if ( ! next && state.current !== 'content' ) { | |
| next = 'content'; | |
| } | |
| if ( ! next ) { | |
| return state; | |
| } | |
| return Object.assign( {}, state, { current: next, next: null } ); | |
| } | |
| } | |
| return state; | |
| } | |