-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #735 from cozy/feat--Flagship-navigation
Feat flagship navigation
- Loading branch information
Showing
17 changed files
with
641 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
dist: focal | ||
language: node_js | ||
node_js: | ||
- "10" | ||
- 16 | ||
env: | ||
global: | ||
# BUNDLESIZE_GITHUB_TOKEN | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ | |
"babel-preset-cozy-app": "^1.9.0", | ||
"bundlesize": "0.18.0", | ||
"cozy-authentication": "1.19.1", | ||
"cozy-intent": "^1.7.0", | ||
"css-loader": "1.0.1", | ||
"css-mqpacker": "7.0.0", | ||
"cssnano-preset-advanced": "4.0.7", | ||
|
@@ -66,6 +67,7 @@ | |
"foreman": "3.0.1", | ||
"identity-obj-proxy": "3.0.0", | ||
"jest": "24.9.0", | ||
"jest-fetch-mock": "^3.0.3", | ||
"json-loader": "0.5.7", | ||
"mini-css-extract-plugin": "0.8.0", | ||
"my-react": "npm:[email protected]", | ||
|
@@ -94,8 +96,8 @@ | |
}, | ||
"dependencies": { | ||
"@cozy/minilog": "^1.0.0", | ||
"cozy-client": "13.8.3", | ||
"cozy-device-helper": "1.8.0", | ||
"cozy-client": "^27.14.4", | ||
"cozy-device-helper": "^1.16.1", | ||
"cozy-flags": "2.4.1", | ||
"cozy-interapp": "0.4.9", | ||
"cozy-realtime": "3.2.1", | ||
|
@@ -112,7 +114,8 @@ | |
"semver-compare": "^1.0.0" | ||
}, | ||
"peerDependencies": { | ||
"cozy-client": "*" | ||
"cozy-client": "*", | ||
"cozy-intent": ">=1.7.0" | ||
}, | ||
"bundlesize": [ | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react' | ||
|
||
import IconCozyHome from './IconCozyHome' | ||
|
||
export const ButtonCozyHome = ({ webviewContext, homeHref }) => { | ||
if (webviewContext) | ||
return ( | ||
<button | ||
onClick={() => { | ||
webviewContext.call('backToHome') | ||
}} | ||
className="coz-nav-apps-btns-home --flagship" | ||
> | ||
<IconCozyHome className="coz-nav-apps-btns-home-svg" /> | ||
</button> | ||
) | ||
|
||
if (homeHref) | ||
return ( | ||
<a href={homeHref} className="coz-nav-apps-btns-home"> | ||
<IconCozyHome className="coz-nav-apps-btns-home-svg" /> | ||
</a> | ||
) | ||
|
||
return ( | ||
<span className="coz-nav-apps-btns-home"> | ||
<IconCozyHome className="coz-nav-apps-btns-home-svg" /> | ||
</span> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react' | ||
import { shallow } from 'enzyme' | ||
|
||
import { ButtonCozyHome } from './ButtonCozyHome' | ||
|
||
const homeHref = 'foo' | ||
const expectedCall = 'backToHome' | ||
const webviewContext = { | ||
call: jest.fn() | ||
} | ||
|
||
describe('ButtonCozyHome', () => { | ||
it('should render a span with no props', () => { | ||
const render = shallow(<ButtonCozyHome />) | ||
const element = render.getElement() | ||
|
||
expect(element.type).toBe('span') | ||
}) | ||
|
||
it('should render an anchor with correct href when homeHref', () => { | ||
const render = shallow(<ButtonCozyHome homeHref={homeHref} />) | ||
const element = render.getElement() | ||
|
||
expect(element.type).toBe('a') | ||
expect(element.props.href).toBe(homeHref) | ||
}) | ||
|
||
it('should render a button when webviewContext', () => { | ||
const render = shallow(<ButtonCozyHome webviewContext={webviewContext} />) | ||
const element = render.getElement() | ||
|
||
expect(element.type).toBe('button') | ||
}) | ||
|
||
it('should give priority to button if both webviewContext and homeHref are present', () => { | ||
const render = shallow( | ||
<ButtonCozyHome homeHref={homeHref} webviewContext={webviewContext} /> | ||
) | ||
const element = render.getElement() | ||
|
||
expect(element.type).toBe('button') | ||
}) | ||
|
||
it('should call the correct context method on click', () => { | ||
const render = shallow( | ||
<ButtonCozyHome homeHref={homeHref} webviewContext={webviewContext} /> | ||
) | ||
|
||
render.simulate('click') | ||
|
||
expect(webviewContext.call).toBeCalledWith(expectedCall) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const SET_WEBVIEW_CONTEXT = 'SET_WEBVIEW_CONTEXT' | ||
|
||
// selectors | ||
export const getWebviewContext = state => { | ||
return state.webviewContext | ||
} | ||
|
||
// actions | ||
export const setWebviewContext = payload => ({ | ||
type: SET_WEBVIEW_CONTEXT, | ||
payload | ||
}) | ||
|
||
// reducers | ||
const defaultState = { | ||
webviewContext: undefined | ||
} | ||
|
||
export const reducer = (state = defaultState, action) => { | ||
switch (action.type) { | ||
case SET_WEBVIEW_CONTEXT: | ||
return { ...state, webviewContext: action.payload } | ||
default: | ||
return state | ||
} | ||
} |
Oops, something went wrong.