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

feat: #KAOS 183-Edit Button, add onClick, Children #52

Merged
merged 2 commits into from
Jul 4, 2023
Merged
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
9 changes: 6 additions & 3 deletions src/components/Button/Delete.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const Delete = ({ label }) => {
const Delete = ({ className, children, onClick }) => {
return (
<button className="button bg-error px-6 text-white hover:bg-errorLight hover:shadow-lg hover:shadow-error/50 active:bg-errorDark active:shadow-error/40">
{label}
<button
className={`button bg-error px-6 text-white hover:bg-errorLight hover:shadow-lg hover:shadow-error/50 active:bg-errorDark active:shadow-error/40 ${className}`}
onClick={onClick}
>
{children}
</button>
);
};
Expand Down
9 changes: 6 additions & 3 deletions src/components/Button/Primary.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const Primary = ({ label }) => {
const Primary = ({ children, onClick, className }) => {
return (
<button className="button active-border-primary-dark border-2 border-primary-base bg-primary-base text-white shadow-lg hover:border-primary-light hover:bg-primary-light hover:shadow-primary-base/50 active:border-primary-dark active:bg-primary-dark active:shadow-inner">
{label}
<button
className={`button active-border-primary-dark border-2 border-primary-base bg-primary-base text-white shadow-lg hover:border-primary-light hover:bg-primary-light hover:shadow-primary-base/50 active:border-primary-dark active:bg-primary-dark active:shadow-inner ${className}`}
onClick={onClick}
>
{children}
</button>
);
};
Expand Down
9 changes: 6 additions & 3 deletions src/components/Button/PrimaryWithIcon.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import Image from "next/image";

const PrimaryWithIcon = ({ label, icon }) => {
const PrimaryWithIcon = ({ icon, className, children, onClick }) => {
return (
<button className="button active-border-primary-dark flex gap-2 border-2 border-primary-base bg-primary-base text-white shadow-lg hover:border-primary-light hover:bg-primary-light hover:shadow-primary-base/50 active:border-primary-dark active:bg-primary-dark active:shadow-inner">
{label}
<button
className={`button active-border-primary-dark flex gap-2 border-2 border-primary-base bg-primary-base text-white shadow-lg hover:border-primary-light hover:bg-primary-light hover:shadow-primary-base/50 active:border-primary-dark active:bg-primary-dark active:shadow-inner ${className} `}
onClick={onClick}
>
{children}
<Image src={icon} width={24} height={24} alt="Add icon" />
</button>
);
Expand Down
9 changes: 6 additions & 3 deletions src/components/Button/Secondary.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const Secondary = ({ label }) => {
const Secondary = ({ children, onClick, className }) => {
return (
<button className="button border-2 border-primary-dark bg-white text-primary-dark hover:shadow-lg active:bg-primary-light active:text-white">
{label}
<button
className={`button border-2 border-primary-dark bg-white text-primary-dark hover:shadow-lg active:bg-primary-light active:text-white ${className} `}
onClick={onClick}
>
{children}
</button>
);
};
Expand Down
49 changes: 49 additions & 0 deletions src/components/TimeInputField.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// //create time input field component for the form with onChange event handler
const TimeInputField = ({ name, label, value, onChange }) => {
return (
<div className="form-group">
<label htmlFor={name}>{label}</label>
<input
type="time"
name={name}
value={value}
onChange={onChange}
className="form-control"
/>
</div>
);
};

export default TimeInputField;

//create time input field component dropdowm for the form with onChange event handler

// const TimeInputField = ({ name, label, value, onChange }) => {
// return (
// <div className="form-group">
// <label htmlFor={name}>{label}</label>
// <select
// name={name}
// value={value}
// onChange={onChange}
// className="form-control"
// >
// <option value="" />
// <option value="1">1:00</option>
// <option value="2">2:00</option>
// <option value="3">3:00</option>
// <option value="4">4:00</option>
// <option value="5">5:00</option>
// <option value="6">6:00</option>
// <option value="7">7:00</option>
// <option value="8">8:00</option>
// <option value="9">9:00</option>
// <option value="10">10:00</option>
// <option value="11">11:00</option>
// <option value="12">12:00</option>
// </select>
// </div>
// );
// }

// export default TimeInputField;
23 changes: 18 additions & 5 deletions src/pages/kaos/testComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import Button from "~/components/Button";
const testComponent = () => {
const isError = true;

const handleClick = () => {
console.log("clicked");
};

return (
<div className="w-100 m-4 flex flex-col gap-4">
Text input field
Expand All @@ -30,15 +34,24 @@ const testComponent = () => {
isError={isError}
/>
</div>
<div className=" flex flex-col gap-2 ">
<Button buttonType={`Primary`} label="I am a button" className="w-12" />
<Button buttonType={`Secondary`} label="I am a button" />
<Button buttonType={`Delete`} label="I am a button" />
<div className="flex flex-col gap-2 ">
<Button buttonType={`Primary`} onClick={handleClick}>
Edit
</Button>
<Button buttonType={`Secondary`} onClick={handleClick}>
Edit
</Button>
<Button buttonType={`Delete`} onClick={handleClick}>
Edit
</Button>
<Button
buttonType={`PrimaryWithIcon`}
label="Waiting for Icon"
icon={AddIcon}
/>
onClick={handleClick}
>
Edit
</Button>
</div>
</div>
);
Expand Down