From 479e2d363ef32ee06b40bdd074c1dfd4f35f60a9 Mon Sep 17 00:00:00 2001 From: Paul Clue <67766160+Paul-Clue@users.noreply.github.com> Date: Thu, 8 Dec 2022 04:17:45 -0500 Subject: [PATCH] Refactor tabs component --- src/views/explore/explore.jsx | 120 ++++++++++++---------------------- 1 file changed, 42 insertions(+), 78 deletions(-) diff --git a/src/views/explore/explore.jsx b/src/views/explore/explore.jsx index 596d4ea30..664c266ee 100644 --- a/src/views/explore/explore.jsx +++ b/src/views/explore/explore.jsx @@ -25,7 +25,6 @@ class Explore extends React.Component { bindAll(this, [ 'getExploreState', 'handleGetExploreMore', - 'changeItemType', 'handleChangeSortMode', 'getBubble', 'getTab' @@ -95,16 +94,7 @@ class Explore extends React.Component { } }); } - changeItemType () { - let newType; - for (const t of this.state.acceptableTypes) { - if (this.state.itemType !== t) { - newType = t; - break; - } - } - window.location = `${window.location.origin}/explore/${newType}/${this.state.tab}/${this.state.mode}`; - } + handleChangeSortMode (name, value) { if (this.state.acceptableModes.indexOf(value) !== -1) { window.location = @@ -117,76 +107,13 @@ class Explore extends React.Component { }); return ( - {classes === 'active' ? [ -
  • - -
  • - ] : [ -
  • - -
  • - ] - } -
    - ); - } - getTab (type) { - const classes = classNames({ - active: (this.state.itemType === type) - }); - return ( - // **** ADD A CONDITIONAL HERE **** -
  • - {this.state.itemType === type ? [ - type === 'projects' ? [ - - ] : [ - - ] - ] : [ - type === 'projects' ? [ - - ] : [ - - ] - ]} - +
  • -
    ); } + render () { return (
    @@ -198,10 +125,47 @@ class Explore extends React.Component {
    - + {/* {this.getTab('projects')} {this.getTab('studios')} - + */} + { + window.location = `${window.location.origin}/explore/projects/${this.state.category}/${this.state.mode}`; + }, + getContent: () =>( +
  • + {this.state.itemType === type ? [ + + ] : [ + + ]} + +
  • + ) + }, + { + name: 'studios', + onTrigger: () => { + window.location = `${window.location.origin}/explore/studios/${this.state.tab}/${this.state.mode}`; + }, + content: 'studios' + } + ]} + activeTabName={ this.state.itemType } + />
    {this.getBubble('all')}