This repository was archived by the owner on Nov 8, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +21
-29
lines changed Expand file tree Collapse file tree 8 files changed +21
-29
lines changed Original file line number Diff line number Diff line change @@ -3,9 +3,9 @@ import styled from 'styled-components'
33import { PinIcon } from '../../components/Icons'
44
55const StyledPin = styled . div `
6- color: ${ props => ( props . isPin ? props . theme . sidebar . pin_active : 'grey' ) } ;
7- visibility: ${ props => ( props . isOpen ? 'visible' : 'hidden' ) } ;
8- opacity: ${ props => ( props . isOpen ? 1 : 0 ) } ;
6+ color: ${ props => ( props . pin ? props . theme . sidebar . pin_active : 'grey' ) } ;
7+ visibility: ${ props => ( props . open ? 'visible' : 'hidden' ) } ;
8+ opacity: ${ props => ( props . open ? 1 : 0 ) } ;
99 position: absolute;
1010 font-size: 25px;
1111 right: 10px;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ const SideBar = styled.div`
55 position: fixed;
66 height: 100vh;
77 top: 0;
8- width: ${ props => ( props . isOpen ? '256px' : '56px' ) } ;
8+ width: ${ props => ( props . open ? '256px' : '56px' ) } ;
99 background: ${ props => props . theme . sidebar . bg } ;
1010 border-color: ${ props => props . theme . sidebar . border_color } ;
1111 z-index: 1000;
Original file line number Diff line number Diff line change @@ -47,10 +47,10 @@ const MenuIcon = ({ name }) => {
4747 }
4848}
4949
50- const MenuList = ( { items, isOpen } ) => {
50+ const MenuList = ( { items, open } ) => {
5151 const listItems = items . map ( item => (
5252 < li key = { item . id } >
53- { isOpen ? (
53+ { open ? (
5454 < span >
5555 < Link href = { item . target . href } as = { item . target . as } >
5656 < span >
@@ -85,14 +85,14 @@ class SidebarContainer extends React.Component {
8585
8686 return (
8787 < Sidebar
88- isOpen = { sidebar . isOpen }
88+ open = { sidebar . open }
8989 onMouseEnter = { logic . enterSidebar }
9090 onMouseLeave = { logic . leaveSidebar }
9191 >
9292 < div >
9393 < PinButton
94- isOpen = { sidebar . isOpen }
95- isPin = { sidebar . isPin }
94+ open = { sidebar . open }
95+ pin = { sidebar . pin }
9696 onClick = { logic . pin }
9797 />
9898 < I18n { ...lang . title } />
@@ -102,7 +102,7 @@ class SidebarContainer extends React.Component {
102102 < br />
103103 < br />
104104 < br />
105- < MenuList items = { sidebar . menuItems } isOpen = { sidebar . isOpen } />
105+ < MenuList items = { sidebar . menuItemsData } open = { sidebar . open } />
106106 </ div >
107107 </ Sidebar >
108108 )
Original file line number Diff line number Diff line change @@ -18,22 +18,21 @@ export const leaveSidebar2 = debounce(() => {
1818*/
1919
2020export function pin ( ) {
21- debug ( 'pin: ' , ! sidebar . isPin )
22- sidebar . markState ( 'pin' , ! sidebar . isPin )
21+ debug ( 'pin: ' , ! sidebar . pin )
22+ sidebar . markState ( 'pin' , ! sidebar . pin )
2323}
2424
2525export function enterSidebar ( ) {
2626 sidebar . markState ( 'open' , true )
2727}
2828
2929export function leaveSidebar ( ) {
30- if ( ! sidebar . isPin ) {
30+ if ( ! sidebar . pin ) {
3131 sidebar . markState ( 'open' , false )
3232 }
3333}
3434
3535export function markLoading ( ) {
36- /* debug('leaveSidebar >>', store.sidebar.menuItems.toJSON()) */
3736 /* sidebar.markLoading() */
3837 debug ( 'markLoading' )
3938 sidebar . markLoading ( )
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ const debug = makeDebugger('S:AppStore')
1515
1616const AppStore = t
1717 . model ( {
18- sidebar : t . optional ( SidebarStore , { allMenuItems : [ ] } ) ,
18+ sidebar : t . optional ( SidebarStore , { menuItems : [ ] } ) ,
1919 // header: t...,
2020 // banner: t...,
2121 body : t . optional ( BodyStore , { } ) ,
Original file line number Diff line number Diff line change @@ -10,6 +10,6 @@ const langSetup = {
1010}
1111
1212it ( 'mini test' , ( ) => {
13- const app = AppStore . create ( { allMenuItems : [ ] , appLangs : langSetup } )
13+ const app = AppStore . create ( { menuItems : [ ] , appLangs : langSetup } )
1414 expect ( app . version ) . toBe ( '0.0.1' )
1515} )
Original file line number Diff line number Diff line change @@ -14,10 +14,9 @@ const debug = makeDebugger('S:SidebarStore')
1414// TODO: test/include sidebarStore and MenuItem
1515const SidebarStore = t
1616 . model ( 'SidebarStore' , {
17- allMenuItems : t . optional ( t . array ( MenuItem ) , [ ] ) , // complex data
17+ menuItems : t . optional ( t . array ( MenuItem ) , [ ] ) , // complex data
1818 open : t . optional ( t . boolean , false ) ,
1919 pin : t . optional ( t . boolean , false ) ,
20- // isPin: t.boolean, // should be in view
2120 // theme: t.string, // view staff
2221 // curSelectItem: t.string, // view staff
2322 // searchBox: t.string, // complex data
@@ -34,14 +33,8 @@ const SidebarStore = t
3433 get langs ( ) {
3534 return self . app . langs
3635 } ,
37- get isOpen ( ) {
38- return self . open
39- } ,
40- get isPin ( ) {
41- return self . pin
42- } ,
43- get menuItems ( ) {
44- return self . allMenuItems . toJSON ( )
36+ get menuItemsData ( ) {
37+ return self . menuItems . toJSON ( )
4538 } ,
4639 get getLoading ( ) {
4740 return self . loading
@@ -53,7 +46,7 @@ const SidebarStore = t
5346 . actions ( self => ( {
5447 loadAllMenuItem ( ) {
5548 debug ( 'loadAllMenuItem ...' )
56- self . allMenuItems = fakeMenuItems
49+ self . menuItems = fakeMenuItems
5750 } ,
5851
5952 markLoading ( ) {
Original file line number Diff line number Diff line change @@ -8,8 +8,8 @@ import SidebarStore from './index'
88it ( 'sidebar store create' , ( ) => {
99 const sidebar = SidebarStore . create ( { } , { } )
1010
11- expect ( sidebar . menuItems . length ) . toBe ( 0 )
11+ expect ( sidebar . menuItemsData . length ) . toBe ( 0 )
1212
1313 sidebar . loadAllMenuItem ( )
14- expect ( sidebar . menuItems . length ) . toBe ( 5 )
14+ expect ( sidebar . menuItemsData . length ) . toBe ( 5 )
1515} )
You can’t perform that action at this time.
0 commit comments