mirror of
https://github.com/wassname/talk.git
synced 2026-08-17 11:27:52 +08:00
replaced eslint:recommended with prettier
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {OPEN_MENU, CLOSE_MENU} from './constants';
|
||||
import { OPEN_MENU, CLOSE_MENU } from './constants';
|
||||
|
||||
export const openMenu = () => ({
|
||||
type: OPEN_MENU,
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import React from 'react';
|
||||
import styles from './Category.css';
|
||||
import {Slot} from 'plugin-api/beta/client/components';
|
||||
import { Slot } from 'plugin-api/beta/client/components';
|
||||
|
||||
const childFactory = (child) => <li className={styles.listItem} key={child.key}>{child}</li>;
|
||||
const childFactory = child => (
|
||||
<li className={styles.listItem} key={child.key}>
|
||||
{child}
|
||||
</li>
|
||||
);
|
||||
|
||||
const ViewingOptions = ({slot, title, data, asset, root}) => {
|
||||
const ViewingOptions = ({ slot, title, data, asset, root }) => {
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
<div className={styles.title}>{title}</div>
|
||||
@@ -14,7 +18,7 @@ const ViewingOptions = ({slot, title, data, asset, root}) => {
|
||||
className={styles.list}
|
||||
component={'ul'}
|
||||
data={data}
|
||||
queryData={{asset, root}}
|
||||
queryData={{ asset, root }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import React from 'react';
|
||||
import cn from 'classnames';
|
||||
import styles from './Menu.css';
|
||||
import {capitalize} from 'plugin-api/beta/client/utils';
|
||||
import {IfSlotIsNotEmpty} from 'plugin-api/beta/client/components';
|
||||
import { capitalize } from 'plugin-api/beta/client/utils';
|
||||
import { IfSlotIsNotEmpty } from 'plugin-api/beta/client/components';
|
||||
import Category from './Category';
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
import { t } from 'plugin-api/beta/client/services';
|
||||
|
||||
class Menu extends React.Component {
|
||||
categories = {
|
||||
@@ -15,16 +15,17 @@ class Menu extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div className={cn([styles.menu, 'talk-plugin-viewing-options-menu'])}>
|
||||
{
|
||||
Object.keys(this.categories).map((category) =>
|
||||
<IfSlotIsNotEmpty slot={`viewingOptions${capitalize(category)}`} key={category}>
|
||||
<Category
|
||||
slot={`viewingOptions${capitalize(category)}`}
|
||||
title={this.categories[category]}
|
||||
/>
|
||||
</IfSlotIsNotEmpty>
|
||||
)
|
||||
}
|
||||
{Object.keys(this.categories).map(category => (
|
||||
<IfSlotIsNotEmpty
|
||||
slot={`viewingOptions${capitalize(category)}`}
|
||||
key={category}
|
||||
>
|
||||
<Category
|
||||
slot={`viewingOptions${capitalize(category)}`}
|
||||
title={this.categories[category]}
|
||||
/>
|
||||
</IfSlotIsNotEmpty>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import React from 'react';
|
||||
import cn from 'classnames';
|
||||
import styles from './ViewingOptions.css';
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
import {Icon} from 'plugin-api/beta/client/components/ui';
|
||||
import {ClickOutside} from 'plugin-api/beta/client/components';
|
||||
import { t } from 'plugin-api/beta/client/services';
|
||||
import { Icon } from 'plugin-api/beta/client/components/ui';
|
||||
import { ClickOutside } from 'plugin-api/beta/client/components';
|
||||
import Menu from './Menu';
|
||||
|
||||
class ViewingOptions extends React.Component {
|
||||
|
||||
toggleOpen = () => {
|
||||
const {open, openMenu, closeMenu} = this.props;
|
||||
const { open, openMenu, closeMenu } = this.props;
|
||||
if (!open) {
|
||||
openMenu();
|
||||
} else {
|
||||
@@ -18,25 +17,28 @@ class ViewingOptions extends React.Component {
|
||||
};
|
||||
|
||||
handleClickOutside = () => {
|
||||
const {open, closeMenu} = this.props;
|
||||
const { open, closeMenu } = this.props;
|
||||
if (open) {
|
||||
closeMenu();
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const {open, data, root, asset} = this.props;
|
||||
const { open, data, root, asset } = this.props;
|
||||
return (
|
||||
<ClickOutside onClickOutside={this.handleClickOutside}>
|
||||
<div className={cn([styles.root, 'talk-plugin-viewing-options'])}>
|
||||
<div>
|
||||
<button className={styles.button} onClick={this.toggleOpen}>
|
||||
<Icon className={styles.icon} name="filter_list" />
|
||||
<span className={styles.label}>{t('talk-plugin-viewing-options.viewing_options')}</span>
|
||||
{open
|
||||
? <Icon name="arrow_drop_up" className={styles.arrowIcon}/>
|
||||
: <Icon name="arrow_drop_down" className={styles.arrowIcon}/>
|
||||
}
|
||||
<span className={styles.label}>
|
||||
{t('talk-plugin-viewing-options.viewing_options')}
|
||||
</span>
|
||||
{open ? (
|
||||
<Icon name="arrow_drop_up" className={styles.arrowIcon} />
|
||||
) : (
|
||||
<Icon name="arrow_drop_down" className={styles.arrowIcon} />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
{open && <Menu data={data} root={root} asset={asset} />}
|
||||
|
||||
@@ -2,4 +2,3 @@ const prefix = 'TALK_VIEWING_OPTIONS';
|
||||
|
||||
export const OPEN_MENU = `${prefix}_OPEN_MENU`;
|
||||
export const CLOSE_MENU = `${prefix}_CLOSE_MENU`;
|
||||
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
import {connect, withFragments} from 'plugin-api/beta/client/hocs';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import { connect, withFragments } from 'plugin-api/beta/client/hocs';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import ViewingOptions from '../components/ViewingOptions';
|
||||
import {openMenu, closeMenu} from '../actions';
|
||||
import {compose, gql} from 'react-apollo';
|
||||
import {getSlotFragmentSpreads} from 'plugin-api/beta/client/utils';
|
||||
import { openMenu, closeMenu } from '../actions';
|
||||
import { compose, gql } from 'react-apollo';
|
||||
import { getSlotFragmentSpreads } from 'plugin-api/beta/client/utils';
|
||||
|
||||
const slots = [
|
||||
'viewingOptionsSort',
|
||||
'viewingOptionsFilter',
|
||||
];
|
||||
const slots = ['viewingOptionsSort', 'viewingOptionsFilter'];
|
||||
|
||||
const mapStateToProps = ({talkPluginViewingOptions: state}) => ({
|
||||
open: state.open
|
||||
const mapStateToProps = ({ talkPluginViewingOptions: state }) => ({
|
||||
open: state.open,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({openMenu, closeMenu}, dispatch);
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators({ openMenu, closeMenu }, dispatch);
|
||||
|
||||
const withViewingOptionsFragments = withFragments({
|
||||
root: gql`
|
||||
@@ -32,7 +29,7 @@ const withViewingOptionsFragments = withFragments({
|
||||
|
||||
const enhance = compose(
|
||||
connect(mapStateToProps, mapDispatchToProps),
|
||||
withViewingOptionsFragments,
|
||||
withViewingOptionsFragments
|
||||
);
|
||||
|
||||
export default enhance(ViewingOptions);
|
||||
|
||||
@@ -5,7 +5,7 @@ import translations from './translations.yml';
|
||||
export default {
|
||||
reducer,
|
||||
slots: {
|
||||
streamFilter: [ViewingOptions]
|
||||
streamFilter: [ViewingOptions],
|
||||
},
|
||||
translations
|
||||
translations,
|
||||
};
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import {OPEN_MENU, CLOSE_MENU} from './constants';
|
||||
import { OPEN_MENU, CLOSE_MENU } from './constants';
|
||||
|
||||
const initialState = {
|
||||
open: false
|
||||
open: false,
|
||||
};
|
||||
|
||||
export default function reducer(state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case OPEN_MENU:
|
||||
return {
|
||||
...state,
|
||||
open: true
|
||||
};
|
||||
case CLOSE_MENU:
|
||||
return {
|
||||
...state,
|
||||
open: false
|
||||
};
|
||||
default :
|
||||
return state;
|
||||
case OPEN_MENU:
|
||||
return {
|
||||
...state,
|
||||
open: true,
|
||||
};
|
||||
case CLOSE_MENU:
|
||||
return {
|
||||
...state,
|
||||
open: false,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user