Skip to content

Commit

Permalink
fix: Popper visual fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Pinedo committed Oct 3, 2022
1 parent a576fd0 commit feb99a5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
14 changes: 10 additions & 4 deletions stories/components/Gallery/Gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ export const Gallery: FC<GalleryProps> = ({ icons, search }) => {
handler: deselect,
});

const handleItemClick = (name, tags) => {
const handleItemClick = (name, tags, Component) => {
const clickedItem =
selectedItem && selectedItem.name[1] === name[1]
? undefined
: new SingleItem(name, search, tags);
: new SingleItem(name, search, tags, Component);
setSelectedItem(clickedItem);
const coords = getItemDOMCoords(clickedItem);
setPopperStyles({
Expand All @@ -76,8 +76,14 @@ export const Gallery: FC<GalleryProps> = ({ icons, search }) => {
{icons.map(({ key, tags, Component }) => (
<Item
key={key[1]}
item={new SingleItem(key, search, tags)}
handleClick={handleItemClick}
item={new SingleItem(key, search, tags, Component)}
handleClick={() =>
handleItemClick(
key,
tags,
<Component key={key} title={key} size={32} />
)
}
isSelected={selectedItem?.name[1] === key[1]}
>
<Component key={key} title={key} size={32} />
Expand Down
2 changes: 1 addition & 1 deletion stories/components/Gallery/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const getStyledInfoContainer = (styles) => styled.div`
position: ${styles.position};
top: ${styles.top}px;
left: ${styles.left - DEFAULT_POPPER_WIDTH / 2}px;
flex-direction: column;
flex-direction: row;
display: flex;
gap: 12px;
z-index: 1;
Expand Down
4 changes: 3 additions & 1 deletion stories/components/Gallery/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ export class SingleItem {
name: [string, string];
match?: string;
tags: string[];
component: React.ReactNode;

constructor(name, match, tags) {
constructor(name, match, tags, component) {
this.name = name;
this.match = match;
this.tags = tags;
this.component = component;
}
}
1 change: 1 addition & 0 deletions stories/components/Popper/Popper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const Popper = forwardRef(function Popper(props: PopperProps, ref) {
>
<div>
<StyledSvgWrapper>
{props.item.component}
<div className={'d-flex flex-js-center'}>
<StyledButton
onClick={() => true}
Expand Down

0 comments on commit feb99a5

Please sign in to comment.