mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-31 21:38:19 +03:00
Replaced tags input component by a simpler one
This commit is contained in:
parent
7efc09d73c
commit
e1008fcff1
6 changed files with 69 additions and 34 deletions
|
@ -28,7 +28,7 @@
|
|||
"react-moment": "^0.7.6",
|
||||
"react-redux": "^5.0.7",
|
||||
"react-router-dom": "^4.2.2",
|
||||
"react-tag-autocomplete": "^5.5.1",
|
||||
"react-tagsinput": "^3.19.0",
|
||||
"reactstrap": "^6.0.1",
|
||||
"redux": "^4.0.0",
|
||||
"redux-thunk": "^2.3.0",
|
||||
|
|
54
src/common/react-tagsinput.scss
Normal file
54
src/common/react-tagsinput.scss
Normal file
|
@ -0,0 +1,54 @@
|
|||
.react-tagsinput {
|
||||
background-color: #fff;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: .25rem;
|
||||
overflow: hidden;
|
||||
min-height: calc(2.6rem + 2px);
|
||||
padding: 6px 0 0 6px;
|
||||
}
|
||||
|
||||
.react-tagsinput--focused {
|
||||
border-color: #80bdff;
|
||||
-webkit-box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
|
||||
box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
|
||||
-webkit-transition: border-color .15s ease-in-out,-webkit-box-shadow .15s ease-in-out;
|
||||
transition: border-color .15s ease-in-out,-webkit-box-shadow .15s ease-in-out;
|
||||
-o-transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
|
||||
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
|
||||
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out,-webkit-box-shadow .15s ease-in-out;
|
||||
}
|
||||
|
||||
.react-tagsinput-tag {
|
||||
font-size: 1rem;
|
||||
background-color: #f1f1f1;
|
||||
border-radius: 2px;
|
||||
border: 1px solid #d1d1d1;
|
||||
display: inline-block;
|
||||
font-weight: 400;
|
||||
margin: 0 5px 6px 0;
|
||||
padding: 6px 8px;
|
||||
line-height: 1;
|
||||
}
|
||||
.react-tagsinput-tag:hover {
|
||||
border-color: #b1b1b1;
|
||||
}
|
||||
|
||||
.react-tagsinput-remove {
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.react-tagsinput-tag a::before {
|
||||
content: "\2715";
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.react-tagsinput-input {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
outline: none;
|
||||
padding: 3px 5px;
|
||||
width: 155px;
|
||||
margin-bottom: 6px;
|
||||
}
|
|
@ -6,6 +6,9 @@ import { BrowserRouter } from 'react-router-dom';
|
|||
import { applyMiddleware, compose, createStore } from 'redux';
|
||||
import ReduxThunk from 'redux-thunk';
|
||||
|
||||
import '../node_modules/react-datepicker/dist/react-datepicker.css';
|
||||
import './common/react-tagsinput.scss';
|
||||
|
||||
import App from './App';
|
||||
import './index.scss';
|
||||
import ScrollToTop from './common/ScrollToTop'
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import downIcon from '@fortawesome/fontawesome-free-solid/faAngleDoubleDown';
|
||||
import upIcon from '@fortawesome/fontawesome-free-solid/faAngleDoubleUp';
|
||||
import FontAwesomeIcon from '@fortawesome/react-fontawesome';
|
||||
import { assoc, dissoc, isNil, pick, pipe, pluck, replace } from 'ramda';
|
||||
import { assoc, dissoc, isNil, pick, pipe, replace, trim } from 'ramda';
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import ReactTags from 'react-tag-autocomplete';
|
||||
import TagsInput from 'react-tagsinput'
|
||||
import { Collapse } from 'reactstrap';
|
||||
import '../../node_modules/react-datepicker/dist/react-datepicker.css';
|
||||
import DateInput from '../common/DateInput';
|
||||
import './CreateShortUrl.scss';
|
||||
import CreateShortUrlResult from './helpers/CreateShortUrlResult';
|
||||
|
@ -26,14 +25,7 @@ export class CreateShortUrl extends React.Component {
|
|||
render() {
|
||||
const { createShortUrl, shortUrlCreationResult, resetCreateShortUrl } = this.props;
|
||||
|
||||
const addTag = tag => this.setState({
|
||||
tags: [].concat(this.state.tags, assoc('name', replace(/ /g, '-', tag.name), tag))
|
||||
});
|
||||
const removeTag = i => {
|
||||
const tags = this.state.tags.slice(0);
|
||||
tags.splice(i, 1);
|
||||
this.setState({ tags });
|
||||
};
|
||||
const changeTags = tags => this.setState({ tags: tags.map(pipe(trim, replace(/ /g, '-'))) });
|
||||
const renderOptionalInput = (id, placeholder, type = 'text', props = {}) =>
|
||||
<input
|
||||
className="form-control"
|
||||
|
@ -56,7 +48,6 @@ export class CreateShortUrl extends React.Component {
|
|||
e.preventDefault();
|
||||
createShortUrl(pipe(
|
||||
dissoc('moreOptionsVisible'), // Remove moreOptionsVisible property
|
||||
assoc('tags', pluck('name', this.state.tags)), // Map tags array to use only their names
|
||||
assoc('validSince', formatDate(this.state.validSince)),
|
||||
assoc('validUntil', formatDate(this.state.validUntil))
|
||||
)(this.state));
|
||||
|
@ -78,12 +69,11 @@ export class CreateShortUrl extends React.Component {
|
|||
|
||||
<Collapse isOpen={this.state.moreOptionsVisible}>
|
||||
<div className="form-group">
|
||||
<ReactTags
|
||||
tags={this.state.tags}
|
||||
handleAddition={addTag}
|
||||
handleDelete={removeTag}
|
||||
allowNew={true}
|
||||
placeholder="Add tags you want to apply to the URL"
|
||||
<TagsInput
|
||||
value={this.state.tags}
|
||||
onChange={changeTags}
|
||||
onlyUnique
|
||||
inputProps={{ placeholder: 'Add tags to the URL' }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -6,18 +6,6 @@
|
|||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.react-tags {
|
||||
@include border-radius(.25rem);
|
||||
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out, -webkit-box-shadow .15s ease-in-out;
|
||||
}
|
||||
.react-tags.is-focused {
|
||||
color: #495057;
|
||||
background-color: #fff;
|
||||
border-color: #80bdff;
|
||||
outline: 0;
|
||||
@include box-shadow(0 0 0 0.2rem rgba(0,123,255,.25));
|
||||
}
|
||||
|
||||
.react-datepicker__input-container,
|
||||
.react-datepicker-wrapper {
|
||||
display: block !important;
|
||||
|
|
|
@ -6190,9 +6190,9 @@ react-router@^4.3.1:
|
|||
prop-types "^15.6.1"
|
||||
warning "^4.0.1"
|
||||
|
||||
react-tag-autocomplete@^5.5.1:
|
||||
version "5.5.1"
|
||||
resolved "https://registry.yarnpkg.com/react-tag-autocomplete/-/react-tag-autocomplete-5.5.1.tgz#6b3f253d3d69eb546925118cdf43138a9aafe113"
|
||||
react-tagsinput@^3.19.0:
|
||||
version "3.19.0"
|
||||
resolved "https://registry.yarnpkg.com/react-tagsinput/-/react-tagsinput-3.19.0.tgz#6e3b45595f2d295d4657bf194491988f948caabf"
|
||||
|
||||
react-test-renderer@^16.0.0-0:
|
||||
version "16.4.2"
|
||||
|
|
Loading…
Reference in a new issue