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

Chore/tag migration #73

Open
wants to merge 25 commits into
base: chore/tailwind-migration
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
25fe782
chore: tag-migration
Harman-singh-waraich Mar 18, 2025
43f04b7
chore: container-migration
Harman-singh-waraich Mar 18, 2025
09a0753
chore: modal-react-aria
Harman-singh-waraich Mar 18, 2025
f6cc60d
chore: display-components-migration
Harman-singh-waraich Mar 18, 2025
8089f5c
chore: tooltip-migration
Harman-singh-waraich Mar 19, 2025
5a0076e
chore: copiable-migration
Harman-singh-waraich Mar 19, 2025
cee9a48
chore: messages-migration
Harman-singh-waraich Mar 19, 2025
6ec1535
chore: checkbox-migration
Harman-singh-waraich Mar 19, 2025
fda7d19
chore: add-react-aria-tailwind-plugin
Harman-singh-waraich Mar 19, 2025
531a826
chore: radio-migration
Harman-singh-waraich Mar 20, 2025
88767bf
chore: switch-migration
Harman-singh-waraich Mar 20, 2025
c96adf1
chore: use-size-utility
Harman-singh-waraich Mar 20, 2025
10f1d91
chore: fields-migration
Harman-singh-waraich Mar 21, 2025
cfd088b
fix: switch-selected-state
Harman-singh-waraich Mar 21, 2025
9e8bb09
fix: checkbox-selected-state
Harman-singh-waraich Mar 21, 2025
524acde
chore: address-feedback
Harman-singh-waraich Mar 21, 2025
0bd959c
feat: button-pressed-animation
Harman-singh-waraich Mar 21, 2025
840558a
chore: searchbar-migration
Harman-singh-waraich Mar 22, 2025
13c5154
chore: file-uploader-migration
Harman-singh-waraich Mar 24, 2025
c95b95e
chore: slider-migration
Harman-singh-waraich Mar 24, 2025
a054072
chore: remove-rc-slider
Harman-singh-waraich Mar 24, 2025
2bfd8a8
chore: datepicker-migration
Harman-singh-waraich Mar 26, 2025
def0d7b
chore: form-component
Harman-singh-waraich Mar 26, 2025
c18e88e
chore: scroll-bar-migration
Harman-singh-waraich Mar 26, 2025
44a4930
chore: dropdown-select-migration
Harman-singh-waraich Mar 27, 2025
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
Prev Previous commit
Next Next commit
chore: searchbar-migration
Harman-singh-waraich committed Mar 22, 2025

Verified

This commit was signed with the committer’s verified signature.
commit 840558a071eda64be6b3f858b8da66303b5544dc
97 changes: 57 additions & 40 deletions src/lib/form/searchbar.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,62 @@
import React from "react";
import styled from "styled-components";
import { borderBox } from "../../styles/common-style";
import SearchIcon from "../../assets/svgs/form/search.svg";
import Field from "./text-field";

const Wrapper = styled.div`
${borderBox}
position: relative;
width: 278px;
`;

const StyledField = styled(Field)`
height: 100%;
width: 100%;
input {
padding: 14px 16px 14px 40px;
}
`;

const StyledSearchIcon = styled(SearchIcon)`
position: absolute;
left: 16px;
top: 50%;
transform: translateY(-50%);
width: 16px;
height: 16px;
max-width: 16px;
max-height: 16px;
fill: ${({ theme }) => theme.klerosUIComponentsPrimaryText};
`;

const Searchbar: React.FC<React.ComponentProps<typeof Field>> = ({
import {
Group,
Input,
type InputProps,
Label,
SearchField,
type SearchFieldProps,
} from "react-aria-components";
import { cn } from "../../utils";
import clsx from "clsx";

interface SearchbarProps extends SearchFieldProps {
label?: string;
/** Props for the input element.
* [See InputProps](https://react-spectrum.adobe.com/react-aria/NumberField.html#input-1)
*/
inputProps?: InputProps;
}
/** A search field allows a user to enter and clear a search query. */
function Searchbar({
label,
inputProps,
className,
...props
}) => (
<Wrapper>
<StyledField placeholder="Search" {...props} />
<StyledSearchIcon />
</Wrapper>
);
}: Readonly<SearchbarProps>) {
return (
<SearchField className={cn("flex w-69.5 flex-col", className)} {...props}>
{label && (
<Label className="text-klerosUIComponentsSecondaryText mb-1 text-sm">
{label}
</Label>
)}
<Group className="relative box-border h-[45px] w-full">
<Input
placeholder={"Search"}
{...inputProps}
className={cn(
"hover-medium-blue hover-short-transition bg-klerosUIComponentsWhiteBackground size-full",
"rounded-base border-klerosUIComponentsStroke text-klerosUIComponentsPrimaryText border",
"placeholder:text-klerosUIComponentsSecondaryText placeholder:opacity-50",
"focus:border-klerosUIComponentsPrimaryBlue focus:shadow-input focus:rounded-base focus:outline-none",
"focus:invalid:border-klerosUIComponentsError focus:invalid:shadow-klerosUIComponentsError",
"py-3.5 pr-4 pl-10",
"invalid:border-klerosUIComponentsError",
"[&::-webkit-search-cancel-button]:hidden",
inputProps?.className,
)}
/>
<SearchIcon
className={clsx(
"absolute top-1/2 left-4 -translate-y-1/2",
"fill-klerosUIComponentsPrimaryText size-4 max-h-4 max-w-4",
)}
/>
</Group>
</SearchField>
);
}

export default Searchbar;
68 changes: 68 additions & 0 deletions src/stories/searchbar.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React from "react";
import type { Meta, StoryObj } from "@storybook/react";

import { IPreviewArgs } from "./utils";

import SearchbarComponent from "../lib/form/searchbar";
import { Form } from "react-aria-components";
import Button from "../lib/button";

const meta = {
component: SearchbarComponent,
title: "Form/Searchbar",
tags: ["autodocs"],
argTypes: {
isRequired: {
control: "boolean",
},
isDisabled: {
control: "boolean",
},
label: {
control: "text",
},
},
} satisfies Meta<typeof SearchbarComponent>;

export default meta;

type Story = StoryObj<typeof meta> & IPreviewArgs;

export const Default: Story = {
args: {
themeUI: "dark",
backgroundUI: "light",
className: "w-[500px]",
},
};

export const Labelled: Story = {
args: {
...Default.args,
label: "Search registry",
},
};

export const Required: Story = {
args: {
...Default.args,
isRequired: true,
},
render: (args) => (
<Form
onSubmit={(e) => {
e.preventDefault();
}}
>
<SearchbarComponent {...args} />
<Button
variant="primary"
type="submit"
aria-pressed="true"
text="Click me!"
small
className="mt-4"
/>
</Form>
),
};