Skip to content

Commit

Permalink
Patterns: use wordpress icons (#88429)
Browse files Browse the repository at this point in the history
  • Loading branch information
nightnei authored Mar 15, 2024
1 parent 3372ace commit 24796fe
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 52 deletions.
5 changes: 0 additions & 5 deletions client/components/category-pill-navigation/images/arrow.svg

This file was deleted.

16 changes: 9 additions & 7 deletions client/components/category-pill-navigation/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Button } from '@wordpress/components';
import { useEffect, useState, useRef } from '@wordpress/element';
import { Icon, chevronRight } from '@wordpress/icons';
import classnames from 'classnames';
import { LocalizedLink } from 'calypso/my-sites/patterns/components/localized-link';

import './style.scss';

type CategoryPillNavigationProps = {
buttons?: {
icon: string;
icon: React.ReactElement< typeof Icon >;
label: string;
link: string;
}[];
Expand Down Expand Up @@ -60,16 +61,17 @@ export const CategoryPillNavigation = ( {
<div className="category-pill-navigation">
<div className="category-pill-navigation__list">
{ showLeftArrow && (
<Button
className="category-pill-navigation__arrow"
onClick={ () => scrollTo( 'left' ) }
/>
<Button className="category-pill-navigation__arrow" onClick={ () => scrollTo( 'left' ) }>
<Icon icon={ chevronRight } size={ 28 } />
</Button>
) }
{ showRightArrow && (
<Button
className="category-pill-navigation__arrow right"
onClick={ () => scrollTo( 'right' ) }
/>
>
<Icon icon={ chevronRight } size={ 28 } />
</Button>
) }
<div
className="category-pill-navigation__list-inner"
Expand All @@ -84,7 +86,7 @@ export const CategoryPillNavigation = ( {
href={ button.link }
className="category-pill-navigation__button"
>
{ button.icon && <img src={ button.icon } alt={ button.label } /> }
{ button.icon }
{ button.label }
</LocalizedLink>
) ) }
Expand Down
3 changes: 2 additions & 1 deletion client/components/category-pill-navigation/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@
}

.category-pill-navigation__arrow {
display: block;
width: 44px;
height: 44px;
position: absolute;
left: 0;
top: 0;
z-index: 2;
background: var(--studio-white) url(./images/arrow.svg) no-repeat center center;
background: var(--studio-white);
transform: rotate(180deg);
cursor: pointer;

Expand Down
9 changes: 0 additions & 9 deletions client/my-sites/patterns/pages/category/images/grid.svg

This file was deleted.

5 changes: 0 additions & 5 deletions client/my-sites/patterns/pages/category/images/list.svg

This file was deleted.

5 changes: 0 additions & 5 deletions client/my-sites/patterns/pages/category/images/star.svg

This file was deleted.

16 changes: 10 additions & 6 deletions client/my-sites/patterns/pages/category/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import {
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
} from '@wordpress/components';
import {
Icon,
starEmpty as iconStar,
category as iconCategory,
menu as iconMenu,
} from '@wordpress/icons';
import { useEffect, useRef, useState } from 'react';
import { CategoryPillNavigation } from 'calypso/components/category-pill-navigation';
import DocumentHead from 'calypso/components/data/document-head';
Expand All @@ -22,8 +28,6 @@ import {
type Pattern,
type PatternGalleryFC,
} from 'calypso/my-sites/patterns/types';
import ImgGrid from './images/grid.svg';
import ImgStar from './images/star.svg';

import './style.scss';

Expand Down Expand Up @@ -111,12 +115,12 @@ export const PatternsCategoryPage = ( {
selectedCategory={ category }
buttons={ [
{
icon: ImgStar,
icon: <Icon icon={ iconStar } size={ 30 } />,
label: 'Discover',
link: addLocaleToPathLocaleInFront( '/patterns' ),
},
{
icon: ImgGrid,
icon: <Icon icon={ iconCategory } size={ 26 } />,
label: 'All Categories',
link: '/222',
},
Expand Down Expand Up @@ -161,12 +165,12 @@ export const PatternsCategoryPage = ( {
>
<ToggleGroupControlOption
className="patterns-page-category__toggle-option--list-view"
label="List view"
label={ ( <Icon icon={ iconMenu } size={ 20 } /> ) as unknown as string }
value="list"
/>
<ToggleGroupControlOption
className="patterns-page-category__toggle-option--grid-view"
label="Grid view"
label={ ( <Icon icon={ iconCategory } size={ 20 } /> ) as unknown as string }
value="grid"
/>
</ToggleGroupControl>
Expand Down
17 changes: 3 additions & 14 deletions client/my-sites/patterns/pages/category/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,14 @@

.patterns-page-category__toggle-option--list-view,
.patterns-page-category__toggle-option--grid-view {
min-width: 34px;

div {
font-size: 0;
}
padding: 0 8px;
color: var(--studio-black);

&[aria-checked="true"] {
filter: invert(100%);
color: var(--studio-white);
}
}

.patterns-page-category__toggle-option--list-view {
background: url(./images/list.svg) no-repeat center center;
}

.patterns-page-category__toggle-option--grid-view {
background: url(./images/grid.svg) no-repeat center center;
}

@media ( max-width: $break-medium ) {
.patterns-page-category__title {
display: none;
Expand Down

0 comments on commit 24796fe

Please sign in to comment.