-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2de5870
commit 55e8d43
Showing
13 changed files
with
2,346 additions
and
3 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
23 changes: 23 additions & 0 deletions
23
src/Sulu/Bundle/AdminBundle/Resources/js/components/QRCode/QRCode.js
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,23 @@ | ||
// @flow | ||
import React, {Fragment} from 'react'; | ||
import QRCodeComponent from 'react-qr-code'; | ||
import Input from '../Input'; | ||
import qrCodeStyles from './qrcode.scss'; | ||
import type {QRCodeProps} from './types'; | ||
|
||
export default class QRCode<T: ?string | ?number> extends React.PureComponent<QRCodeProps<T>> { | ||
render() { | ||
return ( | ||
<Fragment> | ||
<Input | ||
{...this.props} | ||
/> | ||
<QRCodeComponent | ||
className={qrCodeStyles.qrcode} | ||
value={this.props.value || ''} | ||
viewBox="0 0 256 256" | ||
/> | ||
</Fragment> | ||
); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Sulu/Bundle/AdminBundle/Resources/js/components/QRCode/README.md
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,15 @@ | ||
The qr-code component can be used to get an input from the user as a qr-code. | ||
|
||
```javascript | ||
const [value, setValue] = React.useState(''); | ||
|
||
<QRCode value={value} onChange={setValue} /> | ||
``` | ||
|
||
The attributes will be passed to the input component. | ||
|
||
```javascript | ||
const [value, setValue] = React.useState(''); | ||
|
||
<QRCode icon="fa-key" type="password" placeholder="Password" value={value} onChange={setValue} /> | ||
``` |
6 changes: 6 additions & 0 deletions
6
src/Sulu/Bundle/AdminBundle/Resources/js/components/QRCode/index.js
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,6 @@ | ||
// @flow | ||
import QRCode from './QRCode'; | ||
import type {QRCodeProps} from './types'; | ||
|
||
export default QRCode; | ||
export type {QRCodeProps}; |
10 changes: 10 additions & 0 deletions
10
src/Sulu/Bundle/AdminBundle/Resources/js/components/QRCode/qrcode.scss
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,10 @@ | ||
@import '../../containers/Application/colors.scss'; | ||
|
||
.qrcode { | ||
background: white; | ||
height: auto; | ||
margin-top: 20px; | ||
max-width: 100%; | ||
padding: 16px; | ||
width: auto; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Sulu/Bundle/AdminBundle/Resources/js/components/QRCode/tests/QRCode.test.js
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,19 @@ | ||
// @flow | ||
import React from 'react'; | ||
import {render} from 'enzyme'; | ||
import QRCode from '../QRCode'; | ||
|
||
jest.mock('../../../utils/Translator', () => ({ | ||
translate: jest.fn((key) => key), | ||
})); | ||
|
||
test('QRCode should render', () => { | ||
const onChange = jest.fn(); | ||
expect(render(<QRCode | ||
disabled={false} | ||
onBlur={jest.fn()} | ||
onChange={onChange} | ||
valid={false} | ||
value="My value" | ||
/>)).toMatchSnapshot(); | ||
}); |
Oops, something went wrong.