-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into beta-welcome-messaging
- Loading branch information
Showing
16 changed files
with
276 additions
and
38 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
36 changes: 36 additions & 0 deletions
36
ui/components/app/beta-header/__snapshots__/beta-header.test.js.snap
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,36 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Beta Header should match snapshot 1`] = ` | ||
<div> | ||
<div | ||
class="box beta-header box--padding-2 box--display-flex box--flex-direction-row box--width-full box--background-color-warning-default" | ||
> | ||
<h6 | ||
class="box box--flex-direction-row typography beta-header__message typography--h7 typography--weight-normal typography--style-normal typography--color-warning-inverse" | ||
> | ||
<span> | ||
This is a BETA version. Please report bugs | ||
<a | ||
href="https://metamask.zendesk.com/hc/en-us" | ||
rel="noreferrer noopener" | ||
target="_blank" | ||
> | ||
here | ||
</a> | ||
</span> | ||
</h6> | ||
<button | ||
aria-label="Close" | ||
class="beta-header__button" | ||
data-testid="beta-header-close" | ||
> | ||
<i | ||
class="fa fa-times" | ||
/> | ||
</button> | ||
</div> | ||
</div> | ||
`; |
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,24 @@ | ||
import React from 'react'; | ||
import { Provider } from 'react-redux'; | ||
import testData from '../../../../.storybook/test-data'; | ||
import configureStore from '../../../store/store'; | ||
import BetaHeader from '.'; | ||
|
||
const store = configureStore({ | ||
...testData, | ||
metamask: { ...testData.metamask, isUnlocked: true, showBetaHeader: true }, | ||
}); | ||
|
||
export default { | ||
title: 'Components/App/BetaHeader', | ||
decorators: [(story) => <Provider store={store}>{story()}</Provider>], | ||
id: __filename, | ||
}; | ||
|
||
export const DefaultStory = () => ( | ||
<> | ||
<BetaHeader /> | ||
</> | ||
); | ||
|
||
DefaultStory.storyName = 'Default'; |
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,45 @@ | ||
import React from 'react'; | ||
import { fireEvent } from '@testing-library/react'; | ||
import configureMockStore from 'redux-mock-store'; | ||
import thunk from 'redux-thunk'; | ||
import mockState from '../../../../test/data/mock-state.json'; | ||
import { renderWithProvider } from '../../../../test/lib/render-helpers'; | ||
import BetaHeader from '.'; | ||
|
||
const mockHideBetaHeader = jest.fn(); | ||
|
||
jest.mock('../../../store/actions', () => { | ||
return { | ||
hideBetaHeader: () => { | ||
mockHideBetaHeader(); | ||
}, | ||
}; | ||
}); | ||
|
||
describe('Beta Header', () => { | ||
let store; | ||
|
||
beforeEach(() => { | ||
store = configureMockStore([thunk])(mockState); | ||
}); | ||
|
||
afterEach(() => { | ||
mockHideBetaHeader.mockClear(); | ||
}); | ||
|
||
it('should match snapshot', () => { | ||
const { container } = renderWithProvider(<BetaHeader />, store); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
describe('Beta Header', () => { | ||
it('gets hidden when close button is clicked', () => { | ||
const { queryByTestId } = renderWithProvider(<BetaHeader />, store); | ||
|
||
const closeButton = queryByTestId('beta-header-close'); | ||
fireEvent.click(closeButton); | ||
|
||
expect(mockHideBetaHeader).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
}); |
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,59 @@ | ||
import React from 'react'; | ||
import { useI18nContext } from '../../../hooks/useI18nContext'; | ||
|
||
import Box from '../../ui/box/box'; | ||
import Typography from '../../ui/typography/typography'; | ||
import { | ||
TYPOGRAPHY, | ||
COLORS, | ||
BLOCK_SIZES, | ||
DISPLAY, | ||
} from '../../../helpers/constants/design-system'; | ||
import { BETA_BUGS_URL } from '../../../helpers/constants/beta'; | ||
|
||
import { hideBetaHeader } from '../../../store/actions'; | ||
|
||
const BetaHeader = () => { | ||
const t = useI18nContext(); | ||
|
||
return ( | ||
<Box | ||
display={DISPLAY.FLEX} | ||
width={BLOCK_SIZES.FULL} | ||
backgroundColor={COLORS.WARNING_DEFAULT} | ||
padding={2} | ||
className="beta-header" | ||
> | ||
<Typography | ||
variant={TYPOGRAPHY.H7} | ||
marginTop={0} | ||
marginBottom={0} | ||
className="beta-header__message" | ||
color={COLORS.WARNING_INVERSE} | ||
> | ||
{t('betaHeaderText', [ | ||
<a | ||
href={BETA_BUGS_URL} | ||
key="link" | ||
target="_blank" | ||
rel="noreferrer noopener" | ||
> | ||
{t('here')} | ||
</a>, | ||
])} | ||
</Typography> | ||
<button | ||
className="beta-header__button" | ||
data-testid="beta-header-close" | ||
onClick={() => { | ||
hideBetaHeader(); | ||
}} | ||
aria-label={t('close')} | ||
> | ||
<i className="fa fa-times" /> | ||
</button> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default BetaHeader; |
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 @@ | ||
.beta-header { | ||
&__message { | ||
text-align: center; | ||
flex-grow: 1; | ||
} | ||
|
||
&__button { | ||
background: transparent; | ||
padding: 0 6px; | ||
margin: 0; | ||
|
||
i { | ||
color: var(--color-warning-inverse); | ||
} | ||
} | ||
} |
Oops, something went wrong.