Skip to content

Commit

Permalink
Merge pull request #60 from NASA-PDS/search-page-components
Browse files Browse the repository at this point in the history
Add search page components
  • Loading branch information
eddiesarevalo authored Sep 5, 2024
2 parents fb7ddd2 + fc8ea96 commit 67cf724
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 47 deletions.
8 changes: 8 additions & 0 deletions src/components/Button/Button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use "@nasapds/wds/css/button.css";

.MuiButtonBase-root.MuiButton-root{
&.wds-button-cta {
box-shadow: none;
@extend .wds-button-cta;
}
}
17 changes: 17 additions & 0 deletions src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { StoryObj, Meta } from "@storybook/react";
import { TextField } from "./Button";

export default {
component: TextField,
} as Meta<typeof TextField>;
type Story = StoryObj<typeof TextField>;

export const Default: Story = {
args: {},
};

export const Placeholder: Story = {
args: {
placeholder: "placeholder",
},
};
21 changes: 21 additions & 0 deletions src/components/Button/Button.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import renderer from "react-test-renderer";
import { describe, expect, test } from "vitest";
import { TextField } from "./Button";

describe("TextField", () => {
test("TextField component renders correctly", () => {
const component = renderer.create(<TextField />);

const tree = component.toJSON();

expect(tree).toMatchSnapshot();
});

test("The label prop works", () => {
const component = renderer.create(<TextField />);

const tree = component.toJSON();

expect(tree).toMatchSnapshot();
});
});
34 changes: 34 additions & 0 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import MaterialButton from "@mui/material/Button";
import { ButtonProps as MuiBottonProps } from "@mui/material/Button";

type PdsButtonProps = {
variant: "cta";
};

export type ButtonProps = PdsButtonProps & Omit<MuiBottonProps, "variant">;

export const Button = (props: ButtonProps) => {
const { variant, className, ...other } = props;

let buttonClass = "";
let muiVariant;

if (className) {
buttonClass = className + " wds-button";
} else {
buttonClass = "wds-button";
}

switch (variant) {
case "cta":
buttonClass += "-cta";
muiVariant = "contained" as const;
break;
default:
muiVariant = "text" as const;
}

return (
<MaterialButton className={buttonClass} variant={muiVariant} {...other} />
);
};
1 change: 1 addition & 0 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Button";
13 changes: 13 additions & 0 deletions src/components/Chip/Chip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@
border-radius: 4px;
color: var(--pds-secondary-black-t3);
border: 1px solid var(--pds-secondary-blue-t1);
font-size: var(--pds-typography-header-12-semibold-font-size);
line-height: var(--pds-typography-header-12-semibold-line-height);
letter-spacing: var(--pds-typography-header-12-semibold-letter-spacing);
font-weight: var(--pds-typography-header-12-semibold-font-weight);
}

.pds-wds-chip.MuiChip-root:hover{
border: 1px solid var(--pds-secondary-blue-t1);
color: var(--pds-primary-black);
}

.pds-wds-chip .MuiChip-deleteIcon{
height: 10px;
}

.pds-wds-chip .MuiChip-label{
padding-left: 8px;
padding-right: 8px;
}
4 changes: 2 additions & 2 deletions src/components/Chip/Chip.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import MuiChip from "@mui/material/Chip";
import StarsIcon from "@mui/icons-material/Stars";
import CloseIcon from "../Icons/Close";
import { ChipProps } from "@mui/material";

/**
Expand All @@ -14,7 +14,7 @@ export const Chip = ({ ...otherProps }: ChipProps) => {
<MuiChip
className="pds-wds-chip"
variant="outlined"
deleteIcon={<StarsIcon />}
deleteIcon={<CloseIcon />}
{...otherProps}
/>
);
Expand Down
27 changes: 27 additions & 0 deletions src/components/TextField/TextField.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.pds-wds-react-textfield .MuiInputBase-root{
padding: 0 16px 0 16px;
}

.pds-wds-react-textfield .MuiOutlinedInput-notchedOutline {
border-color: var(--pds-secondary-white-s2);
border-radius: 2px;
}

.pds-wds-react-textfield .MuiInputBase-input.MuiOutlinedInput-input{
color: var(--pds-secondary-black-t2);
padding: 16px 0 16px 10px;
}

.pds-wds-react-textfield .MuiInputBase-root:hover .MuiOutlinedInput-notchedOutline{
border-color: var(--pds-secondary-white-s4);
}

.pds-wds-react-textfield .MuiInputBase-root.Mui-focused{
border-color: var(--pds-primary-blue);
}

.pds-wds-react-textfield .MuiInputBase-root.Mui-focused:hover .MuiOutlinedInput-notchedOutline{
border-color: var(--pds-primary-blue);
}


70 changes: 35 additions & 35 deletions src/components/TextField/TextField.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,5 @@
import MaterialTextField from '@mui/material/TextField';
import { TextFieldProps } from '@mui/material/TextField';

const styles = {
textField: {
'& label.Mui-focused': {
},
'& .MuiInput-underline:after': {
borderBottomColor: '#D1D1D1'
},
'& .MuiOutlinedInput-root': {
'& fieldset': {
borderColor:'#D1D1D1',
borderRadius: '2px'
},
'&:hover fieldset': {
borderColor:'#959599'
},
'&.Mui-focused fieldset': {
borderColor:'#1C67E3'
},
input: {
padding: '14px 16px'
},
label: {
},
'& .MuiInputAdornment-root': {
color: '#959599'
}
}
}
}
import MaterialTextField from "@mui/material/TextField";
import { TextFieldProps as MuiTextFieldProps } from "@mui/material/TextField";

/**
* A simple text field.
Expand All @@ -38,13 +8,43 @@ const styles = {
* Default prop values should be specified in the deconstructed parameter object.
*
*/

type PdsTextFieldProps = {
variant?: "standard" | "search";
};

export type TextFieldProps = PdsTextFieldProps &
Omit<MuiTextFieldProps, "variant">;

export const TextField = ({
className,
variant,
...otherProps
}: TextFieldProps) => {
return (
let textFieldClass = "";
let pdsVariant = variant;

if (className) {
textFieldClass = className + " pds-wds-react-textfield";
} else {
textFieldClass = "pds-wds-react-textfield";
}

if (!pdsVariant) {
pdsVariant = "standard";
}

return pdsVariant === "search" ? (
<MaterialTextField
className={textFieldClass}
variant="outlined"
{...otherProps}
/>
) : (
<MaterialTextField
sx={styles.textField}
className={textFieldClass}
variant="outlined"
{...otherProps}
/>
);
}
};
18 changes: 9 additions & 9 deletions src/components/Typography/Typography.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import MuiTypography from "@mui/material/Typography";
import { TypographyProps } from "@mui/material";
import { TypographyProps as MuiTypographyProps } from "@mui/material";
import { StyledEngineProvider } from "@mui/material";

type BodyProps = {
Expand Down Expand Up @@ -57,14 +57,14 @@ type NumberProps = {
};

export type Props =
| (BodyProps & Omit<TypographyProps, "variant">)
| (DisplayProps & Omit<TypographyProps, "variant">)
| (HeaderBLProps & Omit<TypographyProps, "variant">)
| (HeaderBRProps & Omit<TypographyProps, "variant">)
| (HeaderSRProps & Omit<TypographyProps, "variant">)
| (HeaderSProps & Omit<TypographyProps, "variant">)
| (LabelProps & Omit<TypographyProps, "variant">)
| (NumberProps & Omit<TypographyProps, "variant">);
| (BodyProps & Omit<MuiTypographyProps, "variant">)
| (DisplayProps & Omit<MuiTypographyProps, "variant">)
| (HeaderBLProps & Omit<MuiTypographyProps, "variant">)
| (HeaderBRProps & Omit<MuiTypographyProps, "variant">)
| (HeaderSRProps & Omit<MuiTypographyProps, "variant">)
| (HeaderSProps & Omit<MuiTypographyProps, "variant">)
| (LabelProps & Omit<MuiTypographyProps, "variant">)
| (NumberProps & Omit<MuiTypographyProps, "variant">);

export const Typography = (props: Props) => {
const { variant, weight, className, ...other } = props;
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "./styles/styles.scss";
export * from "./components/Breadcrumbs";
export * from "./components/Button";
export * from "./components/Card";
export * from "./components/Chip";
export * from "./components/FeaturedLink";
Expand Down
5 changes: 4 additions & 1 deletion src/styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
@import "_animations";

// Components
@import "../components/Button/Button.scss";
@import "../components/Chip/Chip.scss";
@import "../components/HelloWorld/HelloWorld.scss";
@import "../components/Navbar/Navbar.scss";
@import "../components/Pagination/Pagination.scss";
@import "../components/Tag/Tag.scss";
@import "../components/TextField/TextField.scss";
@import "../components/TitleBar/TitleBar.scss";
@import "../components/Typography/Typography.scss";
@import "../components/Typography/Typography.scss";

0 comments on commit 67cf724

Please sign in to comment.