mirror of
https://github.com/urbit/shrub.git
synced 2024-12-22 18:31:44 +03:00
publish: dropdown component as sidebar sort
also adds 'align' to dropdown component as prop
This commit is contained in:
parent
c3f0743053
commit
9de5ee87af
@ -37,12 +37,23 @@ export class Dropdown extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
let alignment = (!!this.props.align)
|
||||||
|
? this.props.align : "right";
|
||||||
|
|
||||||
let display = (this.state.open)
|
let display = (this.state.open)
|
||||||
? "block" : "none";
|
? "block" : "none";
|
||||||
|
|
||||||
let optionsColor = (this.state.open)
|
let optionsColor = (this.state.open)
|
||||||
? '#e6e6e6' : 'white';
|
? '#e6e6e6' : 'white';
|
||||||
|
|
||||||
|
let leftAlign = "";
|
||||||
|
let rightAlign = "0";
|
||||||
|
|
||||||
|
if (alignment === "left") {
|
||||||
|
leftAlign = "0"
|
||||||
|
rightAlign = ""
|
||||||
|
}
|
||||||
|
|
||||||
let optionsList = this.props.options.map((val, i) => {
|
let optionsList = this.props.options.map((val, i) => {
|
||||||
return (
|
return (
|
||||||
<button key={i} className={val.cls}
|
<button key={i} className={val.cls}
|
||||||
@ -60,9 +71,9 @@ export class Dropdown extends Component {
|
|||||||
onClick={this.toggleDropdown}>
|
onClick={this.toggleDropdown}>
|
||||||
{this.props.buttonText}
|
{this.props.buttonText}
|
||||||
</button>
|
</button>
|
||||||
<div className="absolute flex flex-column pa4 ba b--gray4 br2 z-1 bg-white"
|
<div className="absolute flex flex-column pv2 ba b--gray4 br2 z-1 bg-white"
|
||||||
ref={(el) => {this.optsList = el}}
|
ref={(el) => {this.optsList = el}}
|
||||||
style={{right:0, width:this.props.width, display: display}}>
|
style={{left: leftAlign, right: rightAlign, width:this.props.width, display: display}}>
|
||||||
{optionsList}
|
{optionsList}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { Route, Link } from 'react-router-dom';
|
import { Route, Link } from 'react-router-dom';
|
||||||
|
import { Dropdown } from './dropdown';
|
||||||
import { NotebookItem } from './notebook-item';
|
import { NotebookItem } from './notebook-item';
|
||||||
import { SidebarInvite } from './sidebar-invite';
|
import { SidebarInvite } from './sidebar-invite';
|
||||||
|
|
||||||
@ -149,24 +150,41 @@ export class Sidebar extends Component {
|
|||||||
<a className="db dn-m dn-l dn-xl f9 pb3 pl3" href="/">
|
<a className="db dn-m dn-l dn-xl f9 pb3 pl3" href="/">
|
||||||
⟵ Landscape
|
⟵ Landscape
|
||||||
</a>
|
</a>
|
||||||
<div className="w-100">
|
<div className="w-100 f9">
|
||||||
<Link to="/~publish/new" className="green2 mr4 f9 pl4 pt4 dib">
|
<Link to="/~publish/new" className="green2 mr4 f9 pl4 pt4 dib">
|
||||||
New Notebook
|
New Notebook
|
||||||
</Link>
|
</Link>
|
||||||
<Link to="/~publish/join" className="f9 gray2">
|
<Link to="/~publish/join" className="f9 gray2">
|
||||||
Join Notebook
|
Join Notebook
|
||||||
</Link>
|
</Link>
|
||||||
<div className="dropdown relative bb b--gray4">
|
<div className="pl2 pv2 bb b--gray4">
|
||||||
<select
|
<Dropdown
|
||||||
style={{ WebkitAppearance: "none" }}
|
width="16rem"
|
||||||
className="pl4 pv6 f9 bg-white bg-black-d white-d bn w-100 inter"
|
align="left"
|
||||||
value={this.state.sort}
|
options={[
|
||||||
onChange={this.sortChange}>
|
{
|
||||||
<option value="oldest">Oldest Notebooks First</option>
|
cls: "w-100 tl pointer db ph2 pv3 hover-bg-gray4",
|
||||||
<option value="newest">Newest Notebooks First</option>
|
txt: "Oldest Notebooks First",
|
||||||
<option value="alphabetical">Alphabetical A -> Z</option>
|
action: () => {this.setState({sort: "oldest"})}
|
||||||
<option value="reverseAlphabetical">Alphabetical Z -> A</option>
|
},
|
||||||
</select>
|
{
|
||||||
|
cls: "w-100 tl pointer db ph2 pv3 hover-bg-gray4",
|
||||||
|
txt: "Newest Notebooks First",
|
||||||
|
action: () => {this.setState({sort: "newest"})}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cls: "w-100 tl pointer db ph2 pv3 hover-bg-gray4",
|
||||||
|
txt: "Alphabetical A -> Z",
|
||||||
|
action: () => {this.setState({sort: "alphabetical"})}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cls: "w-100 tl pointer db ph2 pv3 hover-bg-gray4",
|
||||||
|
txt: "Alphabetical Z -> A",
|
||||||
|
action: () => {this.setState({sort: "reverseAlphabetical"})}
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
buttonText="Sort Notebooks"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="overflow-y-scroll h-100">
|
<div className="overflow-y-scroll h-100">
|
||||||
|
@ -54,14 +54,14 @@ export class Subscribers extends Component {
|
|||||||
width = 258;
|
width = 258;
|
||||||
let url = `/~contacts${writePath}`;
|
let url = `/~contacts${writePath}`;
|
||||||
options = [{
|
options = [{
|
||||||
cls: "tl pointer",
|
cls: "tl pointer w-100 db hover-bg-gray4 ph2 pv3",
|
||||||
txt: "Manage this group in the contacts view",
|
txt: "Manage this group in the contacts view",
|
||||||
action: () => {this.redirect(url)}
|
action: () => {this.redirect(url)}
|
||||||
}];
|
}];
|
||||||
} else {
|
} else {
|
||||||
width = 157;
|
width = 157;
|
||||||
options = [{
|
options = [{
|
||||||
cls: "tl pointer",
|
cls: "tl pointer w-100 db hover-bg-gray4 ph2 pv3",
|
||||||
txt: "Demote to subscriber",
|
txt: "Demote to subscriber",
|
||||||
action: () => {this.removeUser(`~${who}`, writePath)}
|
action: () => {this.removeUser(`~${who}`, writePath)}
|
||||||
}];
|
}];
|
||||||
@ -92,11 +92,11 @@ export class Subscribers extends Component {
|
|||||||
let width = 162;
|
let width = 162;
|
||||||
subscribers = this.props.notebook.subscribers.map((who, i) => {
|
subscribers = this.props.notebook.subscribers.map((who, i) => {
|
||||||
let options = [
|
let options = [
|
||||||
{ cls: "tl mb2 pointer",
|
{ cls: "tl pointer w-100 db hover-bg-gray4 ph2 pv3",
|
||||||
txt: "Promote to participant",
|
txt: "Promote to participant",
|
||||||
action: () => {this.addUser(who, writePath)}
|
action: () => {this.addUser(who, writePath)}
|
||||||
},
|
},
|
||||||
{ cls: "tl red2 pointer",
|
{ cls: "tl red2 pointer w-100 db hover-bg-gray4 ph2 pv3",
|
||||||
txt: "Ban",
|
txt: "Ban",
|
||||||
action: () => {this.addUser(who, readPath)}
|
action: () => {this.addUser(who, readPath)}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user