Reconstruct code
This commit is contained in:
parent
0034589837
commit
fdc1578306
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react'
|
import React from "react";
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
function calClassName(selected) {
|
function calClassName(selected) {
|
||||||
|
@ -6,9 +6,9 @@ function calClassName(selected) {
|
||||||
return 'Qr-item';
|
return 'Qr-item';
|
||||||
}
|
}
|
||||||
|
|
||||||
const Style = ({ value, renderer, selected, onClick }) => (
|
const Style = ({ value, renderer, selected, onSelected }) => (
|
||||||
<div className={calClassName(selected)}
|
<div className={calClassName(selected)}
|
||||||
onClick={onClick}>
|
onMouseDown={onSelected}>
|
||||||
<div className="Qr-item-image">
|
<div className="Qr-item-image">
|
||||||
<div className="Qr-item-image-inner">
|
<div className="Qr-item-image-inner">
|
||||||
{renderer}
|
{renderer}
|
||||||
|
@ -24,7 +24,7 @@ Style.propTypes = {
|
||||||
value: PropTypes.string.isRequired,
|
value: PropTypes.string.isRequired,
|
||||||
renderer: PropTypes.object.isRequired,
|
renderer: PropTypes.object.isRequired,
|
||||||
selected: PropTypes.bool.isRequired,
|
selected: PropTypes.bool.isRequired,
|
||||||
onClick: PropTypes.func.isRequired
|
onSelected: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Style;
|
export default Style;
|
||||||
|
|
|
@ -8,7 +8,7 @@ const StyleList = ({ styles, onSelected }) => (
|
||||||
<Style
|
<Style
|
||||||
key={style.value}
|
key={style.value}
|
||||||
{...style}
|
{...style}
|
||||||
onClick={() => onSelected(index)}
|
onSelected={() => onSelected(index)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import {connect} from 'react-redux';
|
||||||
|
import * as React from "react";
|
||||||
|
|
||||||
const mapStateToProps = (state, ownProps) => ({
|
const mapStateToProps = (state, ownProps) => ({
|
||||||
qrcode: state.qrcode,
|
qrcode: state.qrcode,
|
||||||
|
|
|
@ -36,13 +36,18 @@ const mapStateToProps = state => ({
|
||||||
return {
|
return {
|
||||||
value: style.value,
|
value: style.value,
|
||||||
selected: state.selectedIndex == index,
|
selected: state.selectedIndex == index,
|
||||||
renderer: React.createElement(Renderer(style.renderer), {index: index, setParamInfo: setParamInfo})
|
renderer: React.createElement(Renderer(style.renderer), {
|
||||||
|
index: index,
|
||||||
|
setParamInfo: setParamInfo
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
onSelected: index => dispatch(changeStyle(index))
|
onSelected: index => {
|
||||||
|
dispatch(changeStyle(index))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const StyleListViewer = () => {
|
const StyleListViewer = () => {
|
||||||
|
|
|
@ -9,7 +9,6 @@ const initialState = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function appReducer(state = initialState, action) {
|
export default function appReducer(state = initialState, action) {
|
||||||
console.log(state)
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actionTypes.GENERATE_QR_INFO: {
|
case actionTypes.GENERATE_QR_INFO: {
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
|
|
Loading…
Reference in New Issue