Browse Source

Add community refine by searching on new post creation. Fixes #521

unoptim
Dessalines 3 years ago
parent
commit
f0c8082bd9
  1. 6
      assets/css/main.css
  2. 7
      assets/css/selectr.min.css
  3. 1
      package.json
  4. 8
      src/components/post-form.tsx
  5. 1
      src/index.html
  6. 5
      yarn.lock

6
assets/css/main.css

@ -181,3 +181,9 @@ hr {
-webkit-transform: scale(1.2);
-ms-transform: scale(1.2);
}
.selectr-selected, .selectr-options-container {
background-color: var(--secondary);
color: var(--white);
border: unset;
}

7
assets/css/selectr.min.css
File diff suppressed because it is too large
View File

1
package.json

@ -33,6 +33,7 @@
"markdown-it": "^10.0.0",
"markdown-it-container": "^2.0.0",
"markdown-it-emoji": "^1.4.0",
"mobius1-selectr": "^2.4.13",
"moment": "^2.24.0",
"prettier": "^1.18.2",
"reconnecting-websocket": "^4.4.0",

8
src/components/post-form.tsx

@ -35,6 +35,7 @@ import {
} from '../utils';
import autosize from 'autosize';
import Tribute from 'tributejs/src/Tribute.js';
import Selectr from 'mobius1-selectr';
import { i18n } from '../i18next';
const MAX_POST_TITLE_LENGTH = 200;
@ -514,6 +515,13 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
this.state.postForm.community_id = data.communities[0].id;
}
this.setState(this.state);
// Set up select searching
let selectId: any = document.getElementById('post-community');
let selector = new Selectr(selectId, {});
selector.on('selectr.select', option => {
this.state.postForm.community_id = Number(option.value);
});
} else if (res.op == UserOperation.CreatePost) {
let data = res.data as PostResponse;
if (data.post.creator_id == UserService.Instance.user.id) {

1
src/index.html

@ -13,6 +13,7 @@
<!-- Styles -->
<link rel="stylesheet" type="text/css" href="/static/assets/css/tribute.css" />
<link rel="stylesheet" type="text/css" href="/static/assets/css/toastify.css" />
<link rel="stylesheet" type="text/css" href="/static/assets/css/selectr.min.css" />
<link rel="stylesheet" type="text/css" href="/static/assets/css/themes/darkly.min.css" id="darkly" />
<link rel="stylesheet" type="text/css" href="/static/assets/css/main.css" />

5
yarn.lock

@ -3076,6 +3076,11 @@ [email protected]^0.5.1:
dependencies:
minimist "0.0.8"
[email protected]^2.4.13:
version "2.4.13"
resolved "https://registry.yarnpkg.com/mobius1-selectr/-/mobius1-selectr-2.4.13.tgz#0019dfd9f984840d6e40f70683ab3ec78ce3b5df"
integrity sha512-Mk9qDrvU44UUL0EBhbAA1phfQZ7aMZPjwtL7wkpiBzGh8dETGqfsh50mWoX9EkjDlkONlErWXArHCKfoxVg0Bw==
[email protected]^2.24.0:
version "2.24.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"

Loading…
Cancel
Save