feat: Add major UI components and functionality
This adds a major chunk of UI code to the application covering topic listing, topic filtering, subtopic browsing, browsing posts by topic, filtering unread posts, filtering followed posts, sorting posts by recent activity, most activty and most votes, liking/unliking a post, following/unfollowing a post, listing comments and replis in a post. Co-authored-by: Kshitij Sobti <kshitij@sobti.in>
This commit is contained in:
committed by
Kshitij Sobti
parent
322c6ed69c
commit
93d10f9280
@@ -1,36 +1,37 @@
|
||||
import { Dropdown } from '@edx/paragon';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
import { Dropdown } from '@edx/paragon';
|
||||
|
||||
function SelectableDropdown({
|
||||
options, defaultOption, onChange, label,
|
||||
options,
|
||||
onChange,
|
||||
label,
|
||||
}) {
|
||||
const [selected, setSelected] = useState(options.find(option => (option.value === defaultOption)));
|
||||
return (
|
||||
<Dropdown>
|
||||
<Dropdown.Toggle>
|
||||
{ label || selected.label }
|
||||
<Dropdown.Toggle variant="link" size="sm">
|
||||
{label}
|
||||
</Dropdown.Toggle>
|
||||
<Dropdown.Menu>
|
||||
{ options
|
||||
.map(option => (
|
||||
{
|
||||
options.map(option => (
|
||||
<Dropdown.Item
|
||||
type="button"
|
||||
key={option.value}
|
||||
onClick={
|
||||
() => {
|
||||
setSelected(option);
|
||||
if (onChange) {
|
||||
onChange(option);
|
||||
}
|
||||
}
|
||||
() => {
|
||||
if (onChange) {
|
||||
onChange(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
>
|
||||
{ option.label }
|
||||
{option.label}
|
||||
</Dropdown.Item>
|
||||
)) }
|
||||
))
|
||||
}
|
||||
</Dropdown.Menu>
|
||||
|
||||
</Dropdown>
|
||||
);
|
||||
}
|
||||
@@ -42,7 +43,6 @@ SelectableDropdown.propTypes = {
|
||||
label: PropTypes.string,
|
||||
}),
|
||||
).isRequired,
|
||||
defaultOption: PropTypes.string.isRequired,
|
||||
onChange: PropTypes.func,
|
||||
label: PropTypes.node,
|
||||
};
|
||||
@@ -1 +1,2 @@
|
||||
export * from './selectable-dropdown';
|
||||
export { default as PostActionsBar } from '../discussions/posts/post-actions-bar/PostActionsBar';
|
||||
export { default as SelectableDropdown } from './SelectableDropdown';
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
export { default as SelectableDropdown } from './SelectableDropdown';
|
||||
Reference in New Issue
Block a user