Value does not update with clicking - Bootstrap Slider by Seiyria - bootstrap-slider

when I click between the ticks, it doesn't change the "current value" output. How can I fix this?
Maybe someone is able to help me. I will attach a snippet below, so u can try and test.
Thank you very much!
var minSliderValue = $("#mySlider").data("slider-min");
var maxSliderValue = $("#mySlider").data("slider-max");
$('#mySlider').slider({ // if max 100, 150
ticks: [1, 2, 3, 5, 10, 25, 50, 100],
ticks_positions: [0, 10, 20, 35, 50, 65, 82.5, 100],
ticks_labels: ["1x", "2x", "3x", "5x", "10x", "25x", "50x", "100x"],
ticks_snap_bounds: 1, //0.5
ticks_tooltip: true,
step: 1,
max: 100, //JS script
value: 10,
formatter: function (value) {
return value + 'x';
},
});
$("#leverage").on("keyup", function () {
var val = Math.abs(parseInt(this.value, 10) || minSliderValue);
this.value = val > maxSliderValue ? maxSliderValue : val;
$('#mySlider').slider('setValue', val);
});
// Get Value Output //Bug
$("#mySlider").slider();
$("#mySlider").on("slide", function (slideEvt) {
$("#leverage").val(slideEvt.value);
});
body {
background-color: #0f121b!important;
color: #fff!important;
padding: 4rem 2rem;
}
#mySlider {
margin: 2rem;
width: 70%;
}
.slider-tick {
background-color: #ffffff !important;
background-image: none !important;
opacity: 1 !important;
height: 14px !important;
width: 14px !important;
margin: 0.2rem;
}
.slider-handle {
background-color: #ffffff !important;
background-image: none !important;
opacity: 1 !important;
}
.slider-track {
background-image: -webkit-gradient(linear, left top, right top, from(#129b6b), color-stop(#e5d02b), to(#b44b53))!important;
background-image: -o-linear-gradient(left, #129b6b, #e5d02b, #b44b53)!important;
background-image: linear-gradient(to right, #129b6b, #e5d02b, #b44b53)!important;
}
.slider-selection.tick-slider-selection {
background-color: transparent!important;
background-image: none!important;
}
.slider-track-high {
background-color: #2d343e!important;
background-image: none!important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/11.0.2/css/bootstrap-slider.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/11.0.2/bootstrap-slider.js"></script>
<div style="text-align:center">
<div>
<input id="mySlider" data-slider-id='mySliderSlider' type="text" data-slider-min="0" data-slider-max="100" data-slider-step="1" />
<input type="number" id="leverage" min="1" max="100" value="10"
step="1" size="10" inputmode=" decimal">x
<br />
</div>

Use "change" instead of "slide" in the code below, also change slideEvt.value to slideEvt.value.newValue
$("#mySlider").on("slide", function (slideEvt) {
$("#leverage").val(slideEvt.value.newValue);
});
var minSliderValue = $("#mySlider").data("slider-min");
var maxSliderValue = $("#mySlider").data("slider-max");
$('#mySlider').slider({ // if max 100, 150
ticks: [1, 2, 3, 5, 10, 25, 50, 100],
ticks_positions: [0, 10, 20, 35, 50, 65, 82.5, 100],
ticks_labels: ["1x", "2x", "3x", "5x", "10x", "25x", "50x", "100x"],
ticks_snap_bounds: 1, //0.5
ticks_tooltip: true,
step: 1,
max: 100, //JS script
value: 10,
formatter: function (value) {
return value + 'x';
},
});
$("#leverage").on("keyup", function () {
var val = Math.abs(parseInt(this.value, 10) || minSliderValue);
this.value = val > maxSliderValue ? maxSliderValue : val;
$('#mySlider').slider('setValue', val);
});
// Get Value Output //Bug
$("#mySlider").slider();
$("#mySlider").on("change", function (slideEvt) {
$("#leverage").val(slideEvt.value.newValue);
});
body {
background-color: #0f121b!important;
color: #fff!important;
padding: 4rem 2rem;
}
#mySlider {
margin: 2rem;
width: 70%;
}
.slider-tick {
background-color: #ffffff !important;
background-image: none !important;
opacity: 1 !important;
height: 14px !important;
width: 14px !important;
margin: 0.2rem;
}
.slider-handle {
background-color: #ffffff !important;
background-image: none !important;
opacity: 1 !important;
}
.slider-track {
background-image: -webkit-gradient(linear, left top, right top, from(#129b6b), color-stop(#e5d02b), to(#b44b53))!important;
background-image: -o-linear-gradient(left, #129b6b, #e5d02b, #b44b53)!important;
background-image: linear-gradient(to right, #129b6b, #e5d02b, #b44b53)!important;
}
.slider-selection.tick-slider-selection {
background-color: transparent!important;
background-image: none!important;
}
.slider-track-high {
background-color: #2d343e!important;
background-image: none!important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/11.0.2/css/bootstrap-slider.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/11.0.2/bootstrap-slider.js"></script>
<div style="text-align:center">
<div>
<input id="mySlider" data-slider-id='mySliderSlider' type="text" data-slider-min="0" data-slider-max="100" data-slider-step="1" />
<input type="number" id="leverage" min="1" max="100" value="10"
step="1" size="10" inputmode=" decimal">x
<br />
</div>

Related

css text animation not centered on page

I have been having issues centering the text animation on my page, it does not center correctly on all viewports, I have been messing with the keyframes changing them from left: 130px to sometimes 150px to get it centered but it isn't centered properly, that doesn't seem to help, I have also taken off animation-fill mode: forwards, and it seems to just glitch in the middle of the page instead of being a smooth transition. Any help would be appreciated Thanks.
tsParticles.load("tsparticles", {
fps_limit: 60,
interactivity: {
detect_on: "canvas",
events: {
onclick: { enable: true, mode: "push" },
onhover: {
enable: true,
mode: "attract",
parallax: { enable: false, force: 60, smooth: 10 }
},
resize: true
},
modes: {
push: { quantity: 4 },
attract: { distance: 200, duration: 0.4, factor: 5 }
}
},
particles: {
color: { value: "#ffffff" },
line_linked: {
color: "#ffffff",
distance: 150,
enable: true,
opacity: 0.4,
width: 1
},
move: {
attract: { enable: false, rotateX: 600, rotateY: 1200 },
bounce: false,
direction: "none",
enable: true,
out_mode: "out",
random: false,
speed: 2,
straight: false
},
number: { density: { enable: true, value_area: 800 }, value: 80 },
opacity: {
anim: { enable: false, opacity_min: 0.1, speed: 1, sync: false },
random: false,
value: 0.5
},
shape: {
character: {
fill: false,
font: "Verdana",
style: "",
value: "*",
weight: "400"
},
image: {
height: 100,
replace_color: true,
src: "images/github.svg",
width: 100
},
polygon: { nb_sides: 5 },
stroke: { color: "#000000", width: 0 },
type: "circle"
},
size: {
anim: { enable: false, size_min: 0.1, speed: 40, sync: false },
random: true,
value: 5
}
},
polygon: {
draw: { enable: false, lineColor: "#ffffff", lineWidth: 0.5 },
move: { radius: 10 },
scale: 1,
type: "none",
url: ""
},
retina_detect: true
});
const intro = document.querySelector("#intro")
// intro.style.display = "none";
// const timeout = setTimeout(myGreeting, 2000)
// window.onload(function () {
// intro.style.display = "block";
// }
// )
// const myGreeting = () => {
// document.querySelector("#intro").textContent = "Hello Im";
// }
// const timeout = setTimeout(myGreeting, 3000)
const secondGreeting = () => {
document.querySelector(".name").textContent = "Peter Ayad"
}
const timeout2 = setTimeout(secondGreeting, 2500)
const button = document.querySelector('button');
//back to top button
const topButton = document.querySelector('.bTop')
// const divButton = document.querySelector('.divButton');
// divButton.addEventListener('click', function () {
// document.body.scrollTop = 0;
// document.documentElement.scrollTop = 0;
// })
// topButton.addEventListener('click', function () {
// document.body.scrollTop = 0;
// document.documentElement.scrollTop = 0;
// })
// // divButton.addEventListener('click', topFunction)
// window.onscroll = function() {
// topFunction();
// }
window.onscroll = function() {
topFunction();
}
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
topButton = document.querySelector(".bTop");
html {
height: 100vh;
}
body {
margin: 0;
padding: 0;
}
canvas {
display: block;
/* vertical-align: bottom; */
}
/* ---- tsparticles container ---- */
#tsparticles {
position: absolute;
/* position: fixed; */
width: 100%;
height: 100%;
background-color: #0d47a1;
background-image: url("");
background-repeat: no-repeat;
background-size: cover;
background-position: center;
/* background-position: 50% 50%; */
z-index: -1;
}
.github {
bottom: 10px;
right: 10px;
position: fixed;
border-radius: 10px;
background: #fff;
padding: 0 12px 6px 12px;
border: 1px solid #000;
}
.github a:hover,
.github a:link,
.github a:visited,
.github a:active {
color: #000;
text-decoration: none;
}
.github img {
height: 30px;
}
.github #gh-project {
font-size: 20px;
padding-left: 5px;
font-weight: bold;
vertical-align: bottom;
}
.bg-img {
background-repeat: no-repeat;
position: fixed;
background-size: cover;
z-index: -1;
}
#bgCanvas {
background-repeat: no-repeat;
offset-position: center;
position: fixed;
background-size: cover;
z-index: -1;
}
/* span#intro {
margin-top: 40%;
color: white;
} */
.flex {
display: flex;
justify-content: center;
/* margin-top: 50%; */
}
.introParagraph {
display: inline-block;
position : relative;
}
p {
/* margin-top: 0; */
font-family: Roboto, sans-serif;
margin-top: 60%;
margin-bottom: 1rem;
text-align: center;
padding: 2px;
color: white;
}
form {
display: flex;
justify-content: center;
}
/* span#intro {
font-family: Roboto, sans-serif;
display: inline-block;
position: absolute;
animation: appear 2s;
animation-fill-mode: forwards;
margin-top: 35%;
margin-left: 15%;
} */
p#intro {
color: white;
/* position: absolute; */
position: fixed;
animation: appear 2s;
/* animation-fill-mode: forwards; */
margin-top: 35%;
/* color: white; */
/* right: 0; */
}
.name {
margin-left: 39%;
color: white;
}
/* span#intro styles */
#keyframes appear {
from {
left: -100px;
}
to {
left: 140px;
/* left: 30.5%; */
/* text-align: center; */
}
}
#-moz-keyframes appear {
from {
left: -100px;
}
to {
left: 140px;
}
}
#-webkit-keyframes appear {
from {
left: -100px;
}
to {
left: 140px;
}
}
#-o-keyframes appear {
from {
left: -100px;
}
to {
left: 140px;
}
}
.name {
font-family: Roboto, sans-serif;
text-align: center;
display: inline-block;
/* position: absolute; */
position: fixed;
margin-top: 48%;
/* margin-left: 43%; */
}
/* span#intro,
.name,
p {
color: #ffffff;
} */
button {
margin-top: 10%;
/* background-color: initial; */
/* background-color: white; */
border: 2px solid black;
animation: button 2s;
/* padding: 10px; */
border-radius: 5%;
background-color: lightsteelblue;
}
#divButton {
border-radius: 10px;
}
#keyframes button {
0% {
transform:translateY(-100%);
opacity: 0;
}
15% {
transform:translateY(-100%);
opacity: 0;
}
}
/* MEDIA QUERY 720PX */
#media (min-width: 720px) {
span#intro {
color: white;
font-size: 30px;
margin: 0;
margin-top: 20%;
margin-left: 25%;
}
.name {
/* font-family: Roboto, sans-serif;
text-align: center;
display: inline-block;
position: absolute; */
margin-top: 32%;
margin-left: 40%;
font-size: 30px;
}
p.introParagraph {
font-size: 30px;
margin-top: 40%;
}
form {
font-size: 30px;
}
}
/* MEDIA QUERY 1024px */
#media (min-width: 1024px) {
span#intro {
color: white;
font-size: 30px;
margin: 0;
/* margin-top: 20%;
margin-left: 25%; */
margin: 15% 31.5%;
}
.name {
/* margin-top: 35%; */
margin: 25% 43%
}
p.introParagraph {
margin-top: 34%;
}
button {
margin-top: 5%;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <link rel="stylesheet" href="styles2.css"> -->
<!-- <link href='https://unpkg.com/boxicons#2.1.1/css/boxicons.min.css' rel='stylesheet'> -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Dancing+Script&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Amatic+SC&family=Dancing+Script&family=Roboto:wght#100&display=swap" rel="stylesheet">
<link rel="stylesheet" href="styles2.css">
<title>New Portfolio</title>
</head>
<body>
<header class="header1">
<!-- <canvas id="bgCanvas"></canvas> -->
<!-- <video>
<source src="video/153868659.mp4" type="video/mp4" loop autoplay preload="auto">
</video> -->
<!-- <h4 class="name">Peter Ayad</h4> -->
<!-- <nav class="navbar navbar-dark navbar-expand-md"> -->
<!-- <div class="nav_toggle" id="nav-toggle"> -->
<!-- Peter Ayad
<button class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#navLinks" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navLinks"> -->
<!-- <div class="collapse navbar-collapse" id="navLinks"></div> -->
<!-- <ul class="nav_menu" id="nav-menu"> -->
<!-- <ul class="navbar-nav">
<li class="nav-item">Home</li>
<li class="nav-item">About</li>
<li class="nav-item">Resume</li>
<li class="nav-item">Projects</li>
<li class="nav-item">Contact</li>
</ul> -->
<!-- </div> -->
<!-- <i class="bx bxs-grid"> -->
<!-- <i class="bx bxs-grid" data-bs-toggle="collapse" data-bs-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample"></i> -->
<!-- </nav> -->
<!-- <h1 class="mainHeader">Welcome to Peter's Portfolio</h1> -->
</header>
<!-- <canvas id="bgCanvas"></canvas> -->
<!-- Courtesy of CodePen/Vincent Garreau -->
<!-- <p class="codepen" data-height="300" data-default-tab="html,result" data-slug-hash="bGxvQd" data-user="VincentGarreau" style="height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;">
<span>See the Pen <a href="https://codepen.io/VincentGarreau/pen/bGxvQd">
particles.js</a> by Vincent Garreau (#VincentGarreau)
on CodePen.</span>
</p>
<script async src="https://cpwebassets.codepen.io/assets/embed/ei.js"></script>-->
<!-- Courtesy of CodePen/Vincent Garreau -->
<div id="tsparticles"></div>
<section class="mainSection">
<div class="mainPage">
<div class="flex">
<!-- <span id="intro">Hello Im...</span> -->
<p id="intro">Hello Im...</p>
<!-- <div><span class="name">Peter Ayad</span></div> -->
</div>
<div>
<span class="name"></span>
</div>
<p class="introParagraph">
<!-- Peter is a fullstck web developer and react designer. Emmerisve and beautiful websites and apps is his passion. -->
A web developer that is passionate about <span class="create">creating</span> and designing <strong>beautiful</strong>, <span class="immersive">immersive</span>, and <em>interactive</em> websites.
</p>
<!-- <p>Interested in working together? Want to know more about what I do? check out my projects below!</p> -->
<!-- <p>Check out my work</p> -->
<form action="projects.html">
<button id="divButton">Check out my work >></button>
</form>
</div>
</section>
<script async="" defer="" src="https://buttons.github.io/buttons.js"></script>
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/tsparticles#1.37.4/tsparticles.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script src="app2.js"></script>
</body>
</html>

React-bootstrap Dropdown menu incorrectly aligned / positioned from translate3d property

I'm using a React-bootstrap (v1.5.2) dropdown component passing in a custom toggle component, and the dropdown menu renders correctly upon the first click, but subsequent renderings of the dropdown menu causes the menu to appear way out of alignment with the toggle button. It appears that a CSS property, translate3D, mis-calculates the position for the dropdown menu beginning with the second render of the dropdown's menu. I've also noticed that the CSS data attribute, data-popper-placement, changes from its initial value of "bottom-end" to "bottom-start" after the first click on the dropdown button. I'm following the code pattern suggested in the React-bootstrap dropdown docs for custom components, and like I said before, the dropdown menu renders correctly for the first button click.
<Header>
{(headerFixed) => {
return (
<Fragment>
<HomePageNav />
<AssembledDropdownMenu headerFixed={headerFixed}>
{(toggle, setToggleState) => {
return (
<Dropdown
className="d-none d-lg-inline"
onToggle={setToggleState}
>
<Dropdown.Toggle as={toggle} />
<Dropdown.Menu
style={{
borderRadius: "16px",
boxShadow: "0 0 12px 0 rgba(0, 0, 0, 0.2)",
}}
align="right"
popperConfig={{
placement: "bottom-end",
modifiers: [
{
name: "offset",
options: {
offset: [0, 10],
},
},
],
}}
>
<Dropdown.Item href="#/action-1">Action</Dropdown.Item>
<Dropdown.Item href="#/action-2">
Another action
</Dropdown.Item>
<Dropdown.Item href="#/action-3">
Something else
</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
);
}}
</AssembledDropdownMenu>
</Fragment>
);
}}
</Header>
import React, { Fragment, useState } from "react";
import Image from "next/image";
import styled from "styled-components";
export default function AssembledDropdownMenu({ headerFixed, children }) {
let [toggleState, setToggleState] = useState(false);
let toggle = React.forwardRef(({ children, onClick }, ref) => {
return (
<StyledButton
ref={ref}
onClick={(evt) => {
evt.preventDefault();
onClick(evt);
}}
className={
headerFixed ? (toggleState ? "fixed selected" : "fixed") : void 0
}
id="dropdown-custom"
data-display="static"
>
<div>
<Image
layout="fixed"
width={16}
height={16}
src={headerFixed ? "/icons-menu_b.svg" : "/icons-menu_w.svg"}
/>
</div>
<div>
<Image
layout="fixed"
width={24}
height={24}
src={headerFixed ? "/icons-profile_b.svg" : "/icons-profile_w.svg"}
/>
</div>
</StyledButton>
);
});
return children(toggle, setToggleState);
}
const StyledButton = styled.button`
display: flex;
flex-flow: row nowrap;
flex: 0 0 auto;
width: 88px;
height: 40px;
margin: 3px 165px 12px 0px;
padding: 8px 18px;
border-radius: 32px;
box-shadow: 0 3px 12px 0 rgba(0, 0, 0, 0.5);
border: solid 1px rgba(255, 255, 255, 0.5);
background-color: rgba(255, 255, 255, 0.25);
&.fixed {
box-shadow: none;
border: solid 1px #cccccc;
background-color: #ffffff;
}
&.fixed.selected {
box-shadow: 0 3px 12px 0 rgba(0, 0, 0, 0.2);
/*border: solid 1px #cccccc;
background-color: #ffffff;*/
}
& > div {
width: 16px;
height: 16px;
margin: -6px 12px 4px 0;
object-fit: contain;
}
& div + div {
width: 24px;
height: 24px;
margin: -2px 0 0 3px;
object-fit: contain;
}
`;

How to style dropdown with styled-components

I am using React JS + Typescript for my app. For styling I am using styled-components. I am really new in styled components. I have created one dropdown. The logic works fine but the UI looks horrible. I uploaded my code in Code sand box. I want design my Dropdown like Tailwind. But since I am new styled-components, I just don't know how to do that.
This is my dropdown component
import React, { useState } from "react";
import styled from "styled-components";
import Arrow from './Arrow.svg'
const Wrapper = styled.div<
{
active: boolean;
}
>`
text-align: left;
width: 100%;
color: #bfc5cd;
font-size: 16px;
font-weight: 300;
position: relative;
margin: 2em 0;
#media (min-width: 400px) {
max-width: 300px;
}
svg {
fill: #798697;
transition: all 0.2s ease;
}
${props =>
props.active
? `
svg {
transform: rotate(180deg);
}
`
: ``}
`;
const MenuLabel = styled.span`
display:inline-block;
color: grey;
border: 1px solid green;
background: white;
box-shadow: 0 0 5px -1px rgba(0,0,0,0.2);
cursor:pointer;
vertical-align:middle;
max-width: 100px;
padding: 40px 40px;
font-size: 12px;
text-align: center;
border: 1px solid ${({ theme }) => theme.inputBorderColor};
&:focus {
outline: none;
box-shadow: 0px 0px 0px 1px ${({ theme }) => theme.inputBorderColorActive};
border: 1px solid ${({ theme }) => theme.inputBorderColorActive};
}
`;
const ItemList = styled.div`
color: #798697;
background: white;
line-height: 30px;
padding: .25em 2em .25em 2em;
cursor: defaul;
user-select: none;
transition: all .25s ease;
&:hover,
&.selected {
background: #F7F7F7;
color: #4A4A4A;
}
`;
export interface IOptions {
label: string;
value: number;
}
export interface IDropdown {
labelDefault: string;
options: IOptions[];
}
const Dropdown = ({ labelDefault, options }: IDropdown) => {
const [isOpened, setIsOpened] = useState(false);
const [selectedOption, setSelectedOption] = useState("");
const [label, setLabel] = useState("");
const handleSelectedItem = (obj: any) => {
setSelectedOption(obj.value);
setLabel(obj.label);
setIsOpened(!isOpened);
};
return (
<Wrapper active={isOpened}>
<MenuLabel onClick={() => setIsOpened(!isOpened)}>
{selectedOption ? label : labelDefault}
</MenuLabel>
<ul
style={
isOpened
? {
display: "block",
listStyleType: "none"
}
: { display: "none" }
}
>
{options.map(el => (
<ItemList
key={el.value.toString()}
onClick={() => handleSelectedItem(el)}
>
{el.label}
</ItemList>
))}
</ul>
</Wrapper>
);
}
export default Dropdown;
This is the parent component
import * as React from "react";
import Dropdown from "./dropdown";
const MockData = [
{ label: "one", value: 1 },
{ label: "two", value: 2 },
{ label: "three", value: 3 }
];
export default function App() {
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<Dropdown labelDefault="Select a label" options={MockData} />
</div>
);
}

Bootstrap Tags input with Objects as tags typehead Free input not working

I am using bootstrap-tags input (Objects as tags - https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/) for my tags input.
It is working fine with Objects as tags for auto complete suggestions.
But I am trying to active Free input too. So, if tags not in the autosuggest list then it allow to add new tags.
Here is my code:
var tags = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('text'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: {
ttl: 1,
url:'[Json File Path]'
}
});
tags.initialize();
var elt = $('input#tags');
elt.tagsinput({
tagClass: 'badge badge-primary',
itemValue: function(item) {
return item.id;
},
itemText: 'text',
freeInput: true,
typeaheadjs: {
name: 'tags',
displayKey: 'text',
source: tags.ttAdapter()
}
});
Sample Json:
[{"id":15,"text":"money"},{"id":14,"text":"startup"},{"id":13,"text":"inspiration"},{"id":12,"text":"success"},{"id":11,"text":"challenge"}]
jS
var citynames = new Bloodhound({
datumTokenizer:
Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: {
url: 'https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/assets/citynames.json',
filter: function(list) {
return $.map(list, function(cityname) {
return { name: cityname }; });
}
}
});
citynames.initialize();
$('input').tagsinput({
typeaheadjs: {
name: 'citynames',
displayKey: 'name',
valueKey: 'name',
source: citynames.ttAdapter()
}
});
html
<div class="container">
<div class="col-12-xs">
<div class="">
<input type="text" value="Amsterdam,Washington" />
</div>
</div>
</div>
CSS
.icon-github {
background: no-repeat url('../img/github-16px.png');
width: 16px;
height: 16px;
}
.bootstrap-tagsinput {
width: 100%;
}
.accordion {
margin-bottom:-3px;
}
.accordion-group {
border: none;
}
.twitter-typeahead .tt-query,
.twitter-typeahead .tt-hint {
margin-bottom: 0;
}
.twitter-typeahead .tt-hint
{
display: none;
}
.tt-menu {
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
display: none;
float: left;
min-width: 160px;
padding: 5px 0;
margin: 2px 0 0;
list-style: none;
font-size: 14px;
background-color: #ffffff;
border: 1px solid #cccccc;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 4px;
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
background-clip: padding-box;
cursor: pointer;
}
.tt-suggestion {
display: block;
padding: 3px 20px;
clear: both;
font-weight: normal;
line-height: 1.428571429;
color: #333333;
white-space: nowrap;
}
.tt-suggestion:hover,
.tt-suggestion:focus {
color: #ffffff;
text-decoration: none;
outline: 0;
background-color: #428bca;
}
Codepen
Codepen

Add Legend in negativeSeries bar chart

I want to add legend for both positive values and negative values like the image attached.How can I achieve this? Please help me.
My Tried Code is FIDDLE
xSeries = [["a", -1], ["b", 2], ["c", -3], ["d", 5]];
var barChartOptions = {
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
rendererOptions: {
barDirection: 'vertical',
barWidth:10,
varyBarColor: true,
},
fillToZero: true,
fillAxis: 'x',
pointLabels: {
// show: true
},
pointLabels : {
show : true,
hideZeros : true,
location : 's',
ypadding : 12
}
},
legend : {
show : true,
placement : 'outsideGrid',
fontFamily : 'OpenSans-Regular',
marginTop : '100px',
textColor : '#414141',
rowSpacing : '14px',
border : 'none',
background : 'transparent'
},
series : [{
label : "Greater",
lineWidth : 1,
// Use (open) circlular markers.
markerOptions : {
style : "filledCircle"
}
}],
seriesColors: ["#7DAB0B"],
negativeSeriesColors: ["#D99F03"],
axes:{
yaxis:{
renderer: $.jqplot.LinearAxisRenderer,
fontFamily : 'OpenSans-Regular',
label : "kWh",
textColor : '#414141',
tickOptions : {
show : true,
fontFamily : 'OpenSans-Regular',
textColor : '#414141',
fontSize : '10pt'
}
},
xaxis:{
label : "Date",
renderer : $.jqplot.CategoryAxisRenderer,
labelRenderer : $.jqplot.CanvasAxisLabelRenderer,
tickRenderer : $.jqplot.CanvasAxisTickRenderer,
//renderer: $.jqplot.CategoryAxisRenderer,
fontFamily : 'OpenSans-Regular',
textColor : '#414141',
tickOptions : {
angle : -60,
show : true,
fontFamily : 'OpenSans-Regular',
textColor : '#414141',
fontSize : '10pt'
}
},
},
grid : {
background : 'transparent',
gridLineColor : '#c5c5c5'
}
};
try {
var plotBarChart = $.jqplot("chart1", [xSeries], barChartOptions);
} catch (e) {
// alert(e);
}
Make sure your code follows this format.
also be sure to include jquery.jqplot.css
include it: <script src="https://bitbucket.org/cleonello/jqplot/raw/e8af8a37f0f14ea1e8c630ecfe6f1b1933794036/src/jquery.jqplot.css"></script>
Or copy the following code into your css file:
//jquery.jqplot.css
/*rules for the plot target div. These will be cascaded down to all plot elements according to css rules*/
.jqplot-target {
position: relative;
color: #666666;
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 1em;
/* height: 300px;
width: 400px;*/
}
/*rules applied to all axes*/
.jqplot-axis {
font-size: 0.75em;
}
.jqplot-xaxis {
margin-top: 10px;
}
.jqplot-x2axis {
margin-bottom: 10px;
}
.jqplot-yaxis {
margin-right: 10px;
}
.jqplot-y2axis, .jqplot-y3axis, .jqplot-y4axis, .jqplot-y5axis, .jqplot-y6axis, .jqplot-y7axis, .jqplot-y8axis, .jqplot-y9axis, .jqplot-yMidAxis {
margin-left: 10px;
margin-right: 10px;
}
/*rules applied to all axis tick divs*/
.jqplot-axis-tick, .jqplot-xaxis-tick, .jqplot-yaxis-tick, .jqplot-x2axis-tick, .jqplot-y2axis-tick, .jqplot-y3axis-tick, .jqplot-y4axis-tick, .jqplot-y5axis-tick, .jqplot-y6axis-tick, .jqplot-y7axis-tick, .jqplot-y8axis-tick, .jqplot-y9axis-tick, .jqplot-yMidAxis-tick {
position: absolute;
white-space: pre;
}
.jqplot-xaxis-tick {
top: 0px;
/* initial position untill tick is drawn in proper place */
left: 15px;
/* padding-top: 10px;*/
vertical-align: top;
}
.jqplot-x2axis-tick {
bottom: 0px;
/* initial position untill tick is drawn in proper place */
left: 15px;
/* padding-bottom: 10px;*/
vertical-align: bottom;
}
.jqplot-yaxis-tick {
right: 0px;
/* initial position untill tick is drawn in proper place */
top: 15px;
/* padding-right: 10px;*/
text-align: right;
}
.jqplot-yaxis-tick.jqplot-breakTick {
right: -20px;
margin-right: 0px;
padding:1px 5px 1px 5px;
/* background-color: white;*/
z-index: 2;
font-size: 1.5em;
}
.jqplot-y2axis-tick, .jqplot-y3axis-tick, .jqplot-y4axis-tick, .jqplot-y5axis-tick, .jqplot-y6axis-tick, .jqplot-y7axis-tick, .jqplot-y8axis-tick, .jqplot-y9axis-tick {
left: 0px;
/* initial position untill tick is drawn in proper place */
top: 15px;
/* padding-left: 10px;*/
/* padding-right: 15px;*/
text-align: left;
}
.jqplot-yMidAxis-tick {
text-align: center;
white-space: nowrap;
}
.jqplot-xaxis-label {
margin-top: 10px;
font-size: 11pt;
position: absolute;
}
.jqplot-x2axis-label {
margin-bottom: 10px;
font-size: 11pt;
position: absolute;
}
.jqplot-yaxis-label {
margin-right: 10px;
/* text-align: center;*/
font-size: 11pt;
position: absolute;
}
.jqplot-yMidAxis-label {
font-size: 11pt;
position: absolute;
}
.jqplot-y2axis-label, .jqplot-y3axis-label, .jqplot-y4axis-label, .jqplot-y5axis-label, .jqplot-y6axis-label, .jqplot-y7axis-label, .jqplot-y8axis-label, .jqplot-y9axis-label {
/* text-align: center;*/
font-size: 11pt;
margin-left: 10px;
position: absolute;
}
.jqplot-meterGauge-tick {
font-size: 0.75em;
color: #999999;
}
.jqplot-meterGauge-label {
font-size: 1em;
color: #999999;
}
table.jqplot-table-legend {
margin-top: 12px;
margin-bottom: 12px;
margin-left: 12px;
margin-right: 12px;
}
table.jqplot-table-legend, table.jqplot-cursor-legend {
background-color: rgba(255, 255, 255, 0.6);
border: 1px solid #cccccc;
position: absolute;
font-size: 0.75em;
}
td.jqplot-table-legend {
vertical-align:middle;
}
/*
These rules could be used instead of assigning
element styles and relying on js object properties.
*/
/*
td.jqplot-table-legend-swatch {
padding-top: 0.5em;
text-align: center;
}
tr.jqplot-table-legend:first td.jqplot-table-legend-swatch {
padding-top: 0px;
}
*/
td.jqplot-seriesToggle:hover, td.jqplot-seriesToggle:active {
cursor: pointer;
}
.jqplot-table-legend .jqplot-series-hidden {
text-decoration: line-through;
}
div.jqplot-table-legend-swatch-outline {
border: 1px solid #cccccc;
padding:1px;
}
div.jqplot-table-legend-swatch {
width:0px;
height:0px;
border-top-width: 5px;
border-bottom-width: 5px;
border-left-width: 6px;
border-right-width: 6px;
border-top-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-right-style: solid;
}
.jqplot-title {
top: 0px;
left: 0px;
padding-bottom: 0.5em;
font-size: 1.2em;
}
table.jqplot-cursor-tooltip {
border: 1px solid #cccccc;
font-size: 0.75em;
}
.jqplot-cursor-tooltip {
border: 1px solid #cccccc;
font-size: 0.75em;
white-space: nowrap;
background: rgba(208, 208, 208, 0.5);
padding: 1px;
}
.jqplot-highlighter-tooltip, .jqplot-canvasOverlay-tooltip {
border: 1px solid #cccccc;
font-size: 0.75em;
white-space: nowrap;
background: rgba(208, 208, 208, 0.5);
padding: 1px;
}
.jqplot-point-label {
font-size: 0.75em;
z-index: 2;
}
td.jqplot-cursor-legend-swatch {
vertical-align: middle;
text-align: center;
}
div.jqplot-cursor-legend-swatch {
width: 1.2em;
height: 0.7em;
}
.jqplot-error {
/* Styles added to the plot target container when there is an error go here.*/
text-align: center;
}
.jqplot-error-message {
/* Styling of the custom error message div goes here.*/
position: relative;
top: 46%;
display: inline-block;
}
div.jqplot-bubble-label {
font-size: 0.8em;
/* background: rgba(90%, 90%, 90%, 0.15);*/
padding-left: 2px;
padding-right: 2px;
color: rgb(20%, 20%, 20%);
}
div.jqplot-bubble-label.jqplot-bubble-label-highlight {
background: rgba(90%, 90%, 90%, 0.7);
}
div.jqplot-noData-container {
text-align: center;
background-color: rgba(96%, 96%, 96%, 0.3);
}

Resources