Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove bootstrap from sherlock #251

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/sherlock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@
"@fortawesome/react-fontawesome": "^0.2.0",
"downshift": "^9.0.4",
"lodash-es": "^4.17.21",
"react-fast-compare": "^3.2.2",
"reactstrap": "^9.2.2"
"react-fast-compare": "^3.2.2"
},
"peerDependencies": {
"@arcgis/core": "^4.20.0",
"bootstrap": "^4.5.3",
"prop-types": "^15.8.1",
"react": ">=16.8.0"
}
Expand Down
1 change: 0 additions & 1 deletion packages/sherlock/src/Sherlock-InMap.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Map from '@arcgis/core/Map';
import MapView from '@arcgis/core/views/MapView';
import '@arcgis/core/assets/esri/themes/light/main.css';
import * as reactiveUtils from '@arcgis/core/core/reactiveUtils';
import 'bootstrap/dist/css/bootstrap.min.css';
import './Sherlock.css';
import PropTypes from 'prop-types';

Expand Down
43 changes: 39 additions & 4 deletions packages/sherlock/src/Sherlock.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,63 @@
opacity: 1;
background-color: var(--highlight-color);
}

.sherlock button {
background: white;
border: 0;
border-radius: 999px;
font-size: 1rem;
cursor: pointer;
transition:
all 200ms ease-in-out,
scale 100ms ease,
box-shadow 100ms ease;
text-decoration: none;
position: relative;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
scale: 1;
text-shadow: none;
box-shadow: none;
}
.sherlock__input-group {
border: 1px #bbb solid;
padding: 0.5em;
border-radius: 999em;
}
.sherlock input {
outline: none;
border: 0;
font-size: 1em;
}
.sherlock__container {
padding-bottom: 1em;
white-space: nowrap;
}
.sherlock__match-dropdown {
width: var(--width);
width: calc(var(--width) - 50px);
background-color: #fff;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
font-size: 12px;
position: absolute;
z-index: 9999;
margin: 0.5rem;
border-radius: 0.5em;
overflow: hidden;
}
.sherlock__matches {
display: block;
width: 100%;
padding-inline-start: 0;
margin-bottom: 0;
margin: 0;
font-size: 1.2em;
}
.sherlock__match-item {
padding: 2px 12px;
padding: 0.5em 12px;
display: flex;
justify-content: space-between;
}
.sherlock mark {
padding: 0;
background-color: #ffdc00;
}
.sherlock__match-item:hover,
.sherlock__match-item--selected {
Expand Down
54 changes: 33 additions & 21 deletions packages/sherlock/src/Sherlock.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Downshift from 'downshift';
import { escapeRegExp, sortBy, uniqWith } from 'lodash-es';
import PropTypes from 'prop-types';
import { useCallback, useEffect, useState } from 'react';
import { Button, Input, InputGroup } from 'reactstrap';

const defaultSymbols = {
polygon: {
Expand Down Expand Up @@ -38,7 +37,7 @@ export default function Sherlock({
provider,
onSherlockMatch,
label,
placeHolder,
placeHolder = 'Search',
maxResultsToDisplay,
}) {
const handleStateChange = async (feature) => {
Expand Down Expand Up @@ -83,20 +82,20 @@ export default function Sherlock({
}) => (
<div className="sherlock">
<h4>{label}</h4>
<div style={{ paddingBottom: '1em' }}>
<InputGroup>
<Input
<div className="sherlock__container">
<div className="sherlock__input-group">
<button disabled style={{ marginRight: '.5em', color: '#767' }}>
<FontAwesomeIcon icon={faSearch} size="lg" />
</button>
<input
{...getInputProps()}
placeholder={placeHolder}
autoComplete="nope"
></Input>
<Button size="sm" color="secondary" disabled>
<FontAwesomeIcon icon={faSearch} size="lg"></FontAwesomeIcon>
</Button>
</InputGroup>
<div className="sherlock__match-dropdown" {...getMenuProps()}>
<ul className="sherlock__matches">
{!isOpen ? null : (
autoComplete="off"
/>
</div>
{!isOpen ? null : (
<div className="sherlock__match-dropdown" {...getMenuProps()}>
<ul className="sherlock__matches">
<Clue
clue={inputValue}
provider={provider}
Expand All @@ -106,8 +105,11 @@ export default function Sherlock({
if (short) {
return (
<li
className="sherlock__match-item alert-primary"
className="sherlock__match-item"
disabled
style={{
backgroundColor: '#cff4fc',
}}
>
Type more than 2 letters.
</li>
Expand All @@ -117,8 +119,11 @@ export default function Sherlock({
if (error) {
return (
<li
className="sherlock__match-item alert-danger"
className="sherlock__match-item"
disabled
style={{
backgroundColor: '#f8d7da',
}}
>
Error! ${error}
</li>
Expand All @@ -128,8 +133,11 @@ export default function Sherlock({
if (!data.length) {
return (
<li
className="sherlock__match-item alert-warning"
className="sherlock__match-item"
disabled
style={{
background: '#fff3cd',
}}
>
No items found.
</li>
Expand Down Expand Up @@ -164,8 +172,12 @@ export default function Sherlock({
items.push(
<li
key="too-many"
className="sherlock__match-item alert-primary text-center"
className="sherlock__match-item"
disabled
style={{
backgroundColor: '#cff4fc',
textAlign: 'center',
}}
>
More than {maxResultsToDisplay} items found.
</li>,
Expand All @@ -175,9 +187,9 @@ export default function Sherlock({
return items;
}}
</Clue>
)}
</ul>
</div>
</ul>
</div>
)}
</div>
</div>
)}
Expand Down