Diff: STRATO-apps/wordpress_03/app/wp-content/themes/blocksy/static/js/options/containers/Tabs.js
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
import { createElement, Fragment, Component } from '@wordpress/element'
2
+
import OptionsPanel from '../OptionsPanel'
3
+
import classnames from 'classnames'
4
+
import { normalizeCondition, matchValuesWithCondition } from 'match-conditions'
5
+
6
+
export default class Tabs extends Component {
7
+
state = {
8
+
currentTab: 0,
9
+
}
10
+
11
+
render() {
12
+
const filteredTabs = this.props.renderingChunk.filter(
13
+
(singleTab) =>
14
+
!singleTab.condition ||
15
+
matchValuesWithCondition(
16
+
normalizeCondition(singleTab.condition),
17
+
this.props.value
18
+
)
19
+
)
20
+
21
+
const currentTab = filteredTabs[this.state.currentTab]
22
+
23
+
return (
24
+
<div className="ct-tabs">
25
+
<ul>
26
+
{filteredTabs
27
+
.map((singleTab, index) => ({ singleTab, index }))
28
+
.map(({ singleTab, index }) => (
29
+
<li
30
+
key={singleTab.id}
31
+
onClick={() =>
32
+
this.setState({ currentTab: index })
33
+
}
34
+
className={classnames({
35
+
active: index === this.state.currentTab,
36
+
})}>
37
+
{singleTab.title
38
+
? singleTab.title
39
+
: singleTab.id}
40
+
</li>
41
+
))}
42
+
</ul>
43
+
44
+
<div className="ct-current-tab">
45
+
<OptionsPanel
46
+
purpose={this.props.purpose}
47
+
key={currentTab.id}
48
+
onChange={(key, val) => this.props.onChange(key, val)}
49
+
onChangeMultiple={this.props.onChangeMultiple}
50
+
options={currentTab.options}
51
+
value={this.props.value}
52
+
/>
53
+
</div>
54
+
</div>
55
+
)
56
+
}
57
+
}
58
+
59
+
/*
60
+
const Condition = ({ renderingChunk, value, onChange }) =>
61
+
renderingChunk.map(
62
+
conditionOption =>
63
+
matchValuesWithCondition(
64
+
normalizeCondition(conditionOption.condition),
65
+
value
66
+
) ? (
67
+
<OptionsPanel
68
+
key={conditionOption.id}
69
+
onChange={val => onChange({ ...value, ...val })}
70
+
options={conditionOption.options}
71
+
value={value}
72
+
/>
73
+
) : (
74
+
[]
75
+
)
76
+
)
77
+
78
+
export default Condition
79
+
80
+
*/
81
+