mirror of
https://github.com/wassname/talk.git
synced 2026-09-11 12:51:33 +08:00
Port to new Slot property passthrough
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import styles from './Category.css';
|
||||
import { Slot } from 'plugin-api/beta/client/components';
|
||||
|
||||
@@ -8,7 +9,7 @@ const childFactory = child => (
|
||||
</li>
|
||||
);
|
||||
|
||||
const ViewingOptions = ({ slot, title, data, asset, root }) => {
|
||||
const Category = ({ slot, title, slotPassthrough }) => {
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
<div className={styles.title}>{title}</div>
|
||||
@@ -17,11 +18,16 @@ const ViewingOptions = ({ slot, title, data, asset, root }) => {
|
||||
childFactory={childFactory}
|
||||
className={styles.list}
|
||||
component={'ul'}
|
||||
data={data}
|
||||
queryData={{ asset, root }}
|
||||
passthrough={slotPassthrough}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ViewingOptions;
|
||||
Category.propTypes = {
|
||||
slot: PropTypes.string.isRequired,
|
||||
title: PropTypes.string.isRequired,
|
||||
slotPassthrough: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
export default Category;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import cn from 'classnames';
|
||||
import styles from './Menu.css';
|
||||
import { capitalize } from 'plugin-api/beta/client/utils';
|
||||
@@ -13,16 +14,19 @@ class Menu extends React.Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { slotPassthrough } = this.props;
|
||||
return (
|
||||
<div className={cn([styles.menu, 'talk-plugin-viewing-options-menu'])}>
|
||||
{Object.keys(this.categories).map(category => (
|
||||
<IfSlotIsNotEmpty
|
||||
slot={`viewingOptions${capitalize(category)}`}
|
||||
key={category}
|
||||
passthrough={slotPassthrough}
|
||||
>
|
||||
<Category
|
||||
slot={`viewingOptions${capitalize(category)}`}
|
||||
title={this.categories[category]}
|
||||
passthrough={slotPassthrough}
|
||||
/>
|
||||
</IfSlotIsNotEmpty>
|
||||
))}
|
||||
@@ -31,4 +35,8 @@ class Menu extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
Menu.propTypes = {
|
||||
slotPassthrough: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
export default Menu;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import cn from 'classnames';
|
||||
import styles from './ViewingOptions.css';
|
||||
import { t } from 'plugin-api/beta/client/services';
|
||||
@@ -24,7 +25,7 @@ class ViewingOptions extends React.Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { open, data, root, asset } = this.props;
|
||||
const { open, slotPassthrough } = this.props;
|
||||
return (
|
||||
<ClickOutside onClickOutside={this.handleClickOutside}>
|
||||
<div className={cn([styles.root, 'talk-plugin-viewing-options'])}>
|
||||
@@ -41,11 +42,18 @@ class ViewingOptions extends React.Component {
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
{open && <Menu data={data} root={root} asset={asset} />}
|
||||
{open && <Menu slotPassthrough={slotPassthrough} />}
|
||||
</div>
|
||||
</ClickOutside>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ViewingOptions.propTypes = {
|
||||
slotPassthrough: PropTypes.object.isRequired,
|
||||
open: PropTypes.bool.isRequired,
|
||||
openMenu: PropTypes.func.isRequired,
|
||||
closeMenu: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default ViewingOptions;
|
||||
|
||||
Reference in New Issue
Block a user