Skip to content

Commit

Permalink
atomicdata-dev#850 Fix searchbox styling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Polleps authored and joepio committed Feb 29, 2024
1 parent 73fd0fc commit 5e3004c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 28 deletions.
27 changes: 16 additions & 11 deletions browser/data-browser/src/components/forms/InputResourceArray.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { transition } from '../../helpers/transition';
import { FaGripVertical, FaPlus, FaTrash } from 'react-icons/fa6';
import { createPortal } from 'react-dom';
import { transparentize } from 'polished';

interface InputResourceArrayProps extends InputProps {
isA?: string;
Expand Down Expand Up @@ -205,6 +206,7 @@ const DraggableResourceSelector = ({
}: DraggableResourceSelectorProps) => {
const { attributes, listeners, setNodeRef, active } = useDraggable({
id: subject,
disabled: props.disabled,
});

if (subject === undefined) {
Expand All @@ -216,14 +218,17 @@ const DraggableResourceSelector = ({
<ResourceSelector
{...props}
prefix={
<DragHandle
{...listeners}
{...attributes}
type='button'
title='Move item'
>
<FaGripVertical />
</DragHandle>
!props.disabled ? (
<DragHandle
{...listeners}
{...attributes}
disabled={props.disabled}
type='button'
title='Move item'
>
<FaGripVertical />
</DragHandle>
) : null
}
/>
</DragWrapper>
Expand All @@ -246,8 +251,8 @@ const DummySelector = (props: ResourceSelectorProps) => {
};

const StyledDragOverlay = styled(DragOverlay)`
opacity: 0.8;
cursor: grabbing;
--search-box-bg: ${p => transparentize(0.5, p.theme.colors.bg)};
backdrop-filter: blur(3px);
`;

const RelativeContainer = styled.div`
Expand All @@ -258,7 +263,6 @@ const DragHandle = styled.button`
display: flex;
align-items: center;
cursor: grab;
border-radius: ${p => p.theme.radius};
appearance: none;
background: transparent;
border: none;
Expand All @@ -273,6 +277,7 @@ const DragHandle = styled.button`
color: ${p => p.theme.colors.textLight2};
}
`;

const DragWrapper = styled(Row)<{ active: boolean }>`
position: relative;
opacity: ${p => (p.active ? 0.4 : 1)};
Expand Down
24 changes: 13 additions & 11 deletions browser/data-browser/src/components/forms/SearchBox/SearchBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const TriggerButton = styled.button<{ $empty: boolean }>`
align-items: center;
padding: 0.5rem;
border-radius: ${props => props.theme.radius};
background-color: ${props => props.theme.colors.bg};
background: transparent;
border: none;
text-align: start;
height: 2rem;
Expand All @@ -236,10 +236,6 @@ const TriggerButton = styled.button<{ $empty: boolean }>`
overflow: hidden;
cursor: text;
color: ${p => (p.$empty ? p.theme.colors.textLight : p.theme.colors.text)};
&:disabled {
background-color: ${props => props.theme.colors.bg1};
}
`;

const TriggerButtonWrapper = styled.div<{
Expand All @@ -250,15 +246,21 @@ const TriggerButtonWrapper = styled.div<{
p.invalid ? p.theme.colors.alert : p.theme.colors.main};
display: flex;
position: relative;
padding: 1px;
overflow: hidden;
border: 1px solid ${props => props.theme.colors.bg2};
border-radius: ${props => props.theme.radius};
background-color: ${props => props.theme.colors.bg};
background-color: var(--search-box-bg, ${props => props.theme.colors.bg});
&:has(:disabled) {
background-color: ${props => props.theme.colors.bg1};
}
&:has(${TriggerButton}:hover(), ${TriggerButton}:focus-visible) {
}
&:hover,
&:focus-within {
border-color: ${p =>
p.disabled ? 'none' : 'var(--search-box-hightlight)'};
box-shadow: 0 0 0 1px inset var(--search-box-hightlight);
&:focus-visible {
border-color: transparent;
box-shadow: 0 0 0 2px var(--search-box-hightlight);
z-index: 1000;
}
`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { styled } from 'styled-components';

export const SearchBoxButton = styled.button<{ ephimeral?: boolean }>`
background-color: ${p => p.theme.colors.bg};
background-color: transparent;
border: none;
border-left: ${p =>
p.ephimeral ? 'none' : '1px solid ' + p.theme.colors.bg2};
Expand All @@ -18,11 +18,6 @@ export const SearchBoxButton = styled.button<{ ephimeral?: boolean }>`
border-color: var(--search-box-hightlight);
}
&:last-of-type {
border-top-right-radius: ${p => p.theme.radius};
border-bottom-right-radius: ${p => p.theme.radius};
}
visibility: ${p => (p.ephimeral ? 'hidden' : 'visible')};
div:hover > & {
visibility: visible;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ const SearchInputWrapper = styled.div`
}
&:focus-within {
border-color: ${p => p.theme.colors.main};
box-shadow: 0 0 0 1px ${p => p.theme.colors.main};
outline: none;
}
`;
Expand Down

0 comments on commit 5e3004c

Please sign in to comment.