Skip to content

Commit

Permalink
chore: remove redundant type="button" from SfButton (#2990)
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon-dziewonski authored Oct 2, 2023
1 parent 6b0a2f6 commit dc8b924
Show file tree
Hide file tree
Showing 58 changed files with 64 additions and 140 deletions.
6 changes: 1 addition & 5 deletions apps/docs/components/hooks/usePagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ function CustomPagination() {
return (
<nav className="flex justify-between border-t border-neutral-200" role="navigation" aria-label="pagination">
<SfButton
type="button"
aria-label="Go to previous page"
disabled={selectedPage <= 1}
variant="tertiary"
Expand Down Expand Up @@ -150,7 +149,6 @@ function CustomPagination() {
)}
</ul>
<SfButton
type="button"
aria-label="Go to next page"
disabled={selectedPage >= totalPages}
variant="tertiary"
Expand Down Expand Up @@ -178,7 +176,6 @@ const { totalPages, pages, selectedPage, startPage, endPage, next, prev, setPage
<nav class="flex justify-between border-t border-neutral-200" role="navigation" aria-label="pagination">
{{ totalPages }}
<SfButton
type="button"
aria-label="Go to previous page"
:disabled="selectedPage <= 1"
variant="tertiary"
Expand Down Expand Up @@ -280,7 +277,6 @@ const { totalPages, pages, selectedPage, startPage, endPage, next, prev, setPage
</li>
</ul>
<SfButton
type="button"
aria-label="Go to next page"
:disabled="selectedPage >= totalPages"
variant="tertiary"
Expand Down Expand Up @@ -311,7 +307,7 @@ Listed parameters should be passed as object.
| maxPages | `number` | `1` | maximum number of pages to display** |

**there is an additional page displayed when the default number (`1`) is passed. When the current number is `1` then page `2` and the last pages are visible. When the penultimate page is the current one then pages `1` and the last one are visible.


## Return value

Expand Down
4 changes: 1 addition & 3 deletions apps/preview/next/pages/examples/SfDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ function Example() {

return (
<ComponentExample controls={{ state, controls }}>
<SfButton onClick={() => state.set({ ...state.get, open: !state.get.open })} type="button">
Open Drawer
</SfButton>
<SfButton onClick={() => state.set({ ...state.get, open: !state.get.open })}>Open Drawer</SfButton>

<SfDrawer
{...state.get}
Expand Down
5 changes: 1 addition & 4 deletions apps/preview/next/pages/examples/SfModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ function Example() {

return (
<ComponentExample controls={{ state, controls }}>
<SfButton
onClick={() => state.set((currentState) => ({ ...currentState, open: !currentState.open }))}
type="button"
>
<SfButton onClick={() => state.set((currentState) => ({ ...currentState, open: !currentState.open }))}>
Open Modal
</SfButton>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export function Showcase() {
<SfButton
className="relative w-5 h-5 !p-0 rounded-sm outline-secondary-600 hover:bg-transparent active:bg-transparent"
aria-label="More breadcrumbs"
type="button"
variant="tertiary"
slotPrefix={
<SfIconMoreHoriz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export function Showcase() {
<SfButton
className="relative w-5 h-5 !p-0 rounded-sm outline-secondary-600 hover:bg-transparent active:bg-transparent"
aria-label="More breadcrumbs"
type="button"
variant="tertiary"
slotPrefix={
<SfIconMoreHoriz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export function Showcase() {
<SfButton
className="relative w-5 h-5 !p-0 rounded-sm outline-secondary-600 hover:bg-transparent active:bg-transparent"
aria-label="More breadcrumbs"
type="button"
variant="tertiary"
slotPrefix={
<SfIconMoreHoriz
Expand Down
6 changes: 1 addition & 5 deletions apps/preview/next/pages/showcases/Button/ButtonBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { ShowcasePageLayout } from '../../showcases';
import { SfButton } from '@storefront-ui/react';

export default function ButtonBlock() {
return (
<SfButton type="button" className="w-full">
Hello
</SfButton>
);
return <SfButton className="w-full">Hello</SfButton>;
}
// #endregion source
ButtonBlock.getLayout = ShowcasePageLayout;
2 changes: 1 addition & 1 deletion apps/preview/next/pages/showcases/Button/ButtonContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function ButtonContent() {

<SfButton slotSuffix={<SfIconStar />}>Hello</SfButton>

<SfButton type="button" square aria-label="Add to cart">
<SfButton square aria-label="Add to cart">
<SfIconShoppingCart />
</SfButton>
</div>
Expand Down
12 changes: 3 additions & 9 deletions apps/preview/next/pages/showcases/Button/ButtonSizes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ import { SfButton } from '@storefront-ui/react';
export default function ButtonSizes() {
return (
<div className="flex flex-col items-center space-y-4 xs:block xs:space-x-4">
<SfButton type="button" size="sm">
Hello
</SfButton>
<SfButton size="sm">Hello</SfButton>

<SfButton type="button" size="base">
Hello
</SfButton>
<SfButton size="base">Hello</SfButton>

<SfButton type="button" size="lg">
Hello
</SfButton>
<SfButton size="lg">Hello</SfButton>
</div>
);
}
Expand Down
12 changes: 3 additions & 9 deletions apps/preview/next/pages/showcases/Button/ButtonVariants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ import { SfButton } from '@storefront-ui/react';
export default function ButtonVariants() {
return (
<div className="flex flex-col items-center space-y-4 xs:block xs:space-x-4">
<SfButton type="button" variant="primary">
Hello
</SfButton>
<SfButton variant="primary">Hello</SfButton>

<SfButton type="button" variant="secondary">
Hello
</SfButton>
<SfButton variant="secondary">Hello</SfButton>

<SfButton type="button" variant="tertiary">
Hello
</SfButton>
<SfButton variant="tertiary">Hello</SfButton>
</div>
);
}
Expand Down
4 changes: 1 addition & 3 deletions apps/preview/next/pages/showcases/Drawer/Placement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ export default function DrawerDemo() {
<option value="left">left</option>
</select>
</label>
<SfButton onClick={() => setOpen(true)} type="button">
Open Drawer
</SfButton>
<SfButton onClick={() => setOpen(true)}>Open Drawer</SfButton>

<SfDrawer
open={open}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ export default function DrawerWithTransition() {
</label>
))}
</fieldset>
<SfButton onClick={() => setOpen(true)} type="button">
Open Drawer
</SfButton>
<SfButton onClick={() => setOpen(true)}>Open Drawer</SfButton>

<Transition ref={nodeRef} in={open} timeout={300}>
{(state) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ export default function FormFields() {
</fieldset>
<p className="text-neutral-500 typography-text-sm mt-8">* marked fields are required</p>
<div className="flex gap-x-4 md:justify-end mt-6">
<SfButton type="button" variant="secondary" className="flex-grow md:flex-grow-0">
<SfButton variant="secondary" className="flex-grow md:flex-grow-0">
Clear all
</SfButton>
<SfButton type="submit" className="flex-grow md:flex-grow-0">
Expand Down
2 changes: 0 additions & 2 deletions apps/preview/next/pages/showcases/MegaMenu/BaseMegaMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ export default function BaseMegaMenu() {
<div className="flex items-center justify-start h-full max-w-[1536px] w-full px-4 md:px-10">
<SfButton
className="block md:hidden text-white bg-transparent font-body hover:bg-primary-800 hover:text-white active:bg-primary-900 active:text-white"
type="button"
aria-haspopup="true"
aria-expanded={isOpen}
variant="tertiary"
Expand All @@ -192,7 +191,6 @@ export default function BaseMegaMenu() {
</a>
<SfButton
className="hidden md:flex text-white bg-transparent font-body hover:bg-primary-800 hover:text-white active:bg-primary-900 active:text-white"
type="button"
aria-haspopup="true"
aria-expanded={isOpen}
slotSuffix={<SfIconExpandMore className="hidden md:inline-flex" />}
Expand Down
10 changes: 3 additions & 7 deletions apps/preview/next/pages/showcases/Modal/ModalBasic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ export default function ModalDemo() {

return (
<>
<SfButton type="button" onClick={open}>
To Checkout
</SfButton>
<SfButton onClick={open}>To Checkout</SfButton>

<SfModal
open={isOpen}
Expand All @@ -33,12 +31,10 @@ export default function ModalDemo() {
proceeding to checkout page?
</p>
<footer className="flex justify-end gap-4 mt-4">
<SfButton type="button" variant="secondary" onClick={close}>
<SfButton variant="secondary" onClick={close}>
Skip
</SfButton>
<SfButton type="button" onClick={close}>
Yes!
</SfButton>
<SfButton onClick={close}>Yes!</SfButton>
</footer>
</SfModal>
</>
Expand Down
10 changes: 3 additions & 7 deletions apps/preview/next/pages/showcases/Modal/ModalTransition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ export default function ModalTransition() {

return (
<>
<SfButton type="button" onClick={open}>
To Checkout
</SfButton>
<SfButton onClick={open}>To Checkout</SfButton>

{/* Backdrop */}
<CSSTransition
Expand Down Expand Up @@ -67,12 +65,10 @@ export default function ModalTransition() {
proceeding to checkout page?
</p>
<footer className="flex justify-end gap-4 mt-4">
<SfButton type="button" variant="secondary" onClick={close}>
<SfButton variant="secondary" onClick={close}>
Skip
</SfButton>
<SfButton type="button" onClick={close}>
Yes!
</SfButton>
<SfButton onClick={close}>Yes!</SfButton>
</footer>
</SfModal>
</CSSTransition>
Expand Down
1 change: 0 additions & 1 deletion apps/preview/next/pages/showcases/NavbarTop/NavbarTop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export default function TopNav() {
</SfButton>
<SfButton
className="hidden lg:flex lg:mr-4"
type="button"
variant="tertiary"
slotSuffix={<SfIconExpandMore className="hidden lg:block" />}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export default function TopNavFilled() {
</SfButton>
<SfButton
className="hidden lg:flex lg:mr-4 text-white hover:text-white active:text-white hover:bg-primary-800 active:bg-primary-900"
type="button"
variant="tertiary"
slotSuffix={<SfIconExpandMore className="hidden lg:block" />}
>
Expand Down
2 changes: 0 additions & 2 deletions apps/preview/next/pages/showcases/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export function Showcase() {
aria-label="pagination"
>
<SfButton
type="button"
size="lg"
className="gap-3 !px-3 sm:px-6"
aria-label="Go to previous page"
Expand Down Expand Up @@ -150,7 +149,6 @@ export function Showcase() {
)}
</ul>
<SfButton
type="button"
size="lg"
aria-label="Go to next page"
disabled={selectedPage >= totalPages}
Expand Down
8 changes: 3 additions & 5 deletions apps/preview/next/pages/showcases/ProductCard/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export default function ProductDetails() {
<div className="flex flex-col items-stretch xs:items-center xs:inline-flex">
<div className="flex border border-neutral-300 rounded-md">
<SfButton
type="button"
variant="tertiary"
square
className="rounded-r-none p-3"
Expand All @@ -86,7 +85,6 @@ export default function ProductDetails() {
onChange={handleOnChange}
/>
<SfButton
type="button"
variant="tertiary"
square
className="rounded-l-none p-3"
Expand All @@ -102,15 +100,15 @@ export default function ProductDetails() {
<strong className="text-neutral-900">{max}</strong> in stock
</p>
</div>
<SfButton type="button" size="lg" className="w-full xs:ml-4" slotPrefix={<SfIconShoppingCart size="sm" />}>
<SfButton size="lg" className="w-full xs:ml-4" slotPrefix={<SfIconShoppingCart size="sm" />}>
Add to cart
</SfButton>
</div>
<div className="flex justify-center mt-4 gap-x-4">
<SfButton type="button" size="sm" variant="tertiary" slotPrefix={<SfIconCompareArrows size="sm" />}>
<SfButton size="sm" variant="tertiary" slotPrefix={<SfIconCompareArrows size="sm" />}>
Compare
</SfButton>
<SfButton type="button" size="sm" variant="tertiary" slotPrefix={<SfIconFavorite size="sm" />}>
<SfButton size="sm" variant="tertiary" slotPrefix={<SfIconFavorite size="sm" />}>
Add to list
</SfButton>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export default function ProductCardHorizontal() {
<div className="flex items-center justify-between mt-4 sm:mt-0">
<div className="flex border border-neutral-300 rounded-md">
<SfButton
type="button"
variant="tertiary"
square
className="rounded-r-none"
Expand All @@ -75,7 +74,6 @@ export default function ProductCardHorizontal() {
onChange={handleOnChange}
/>
<SfButton
type="button"
variant="tertiary"
square
className="rounded-l-none"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default function ProductCardVertical() {
/>
</SfLink>
<SfButton
type="button"
variant="tertiary"
size="sm"
square
Expand All @@ -41,7 +40,7 @@ export default function ProductCardVertical() {
Lightweight • Non slip • Flexible outsole • Easy to wear on and off
</p>
<span className="block pb-2 font-bold typography-text-lg">$2345,99</span>
<SfButton type="button" size="sm" slotPrefix={<SfIconShoppingCart size="sm" />}>
<SfButton size="sm" slotPrefix={<SfIconShoppingCart size="sm" />}>
Add to cart
</SfButton>
</div>
Expand Down
1 change: 0 additions & 1 deletion apps/preview/next/pages/showcases/ProductSlider/Basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export default function GalleryVertical() {
/>
</SfLink>
<SfButton
type="button"
variant="tertiary"
size="sm"
square
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default function OutOfStockDemo() {
<div className="flex rounded-md border border-disabled-200 bg-disabled-100">
<SfButton
variant="tertiary"
type="button"
square
disabled
aria-controls={inputId}
Expand All @@ -31,7 +30,7 @@ export default function OutOfStockDemo() {
max={max}
/>

<SfButton variant="tertiary" type="button" square disabled aria-controls={inputId} aria-label="Increase value">
<SfButton variant="tertiary" square disabled aria-controls={inputId} aria-label="Increase value">
<SfIconAdd />
</SfButton>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default function QuantitySelector() {
<div className="inline-flex flex-col items-center">
<div className="flex border border-neutral-300 rounded-md">
<SfButton
type="button"
variant="tertiary"
square
className="rounded-r-none"
Expand All @@ -41,7 +40,6 @@ export default function QuantitySelector() {
onChange={handleOnChange}
/>
<SfButton
type="button"
variant="tertiary"
square
className="rounded-l-none"
Expand Down
Loading

0 comments on commit dc8b924

Please sign in to comment.