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

Don't display Guide's page control if there is only one page #29629

Merged
merged 2 commits into from
Mar 15, 2021
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
12 changes: 7 additions & 5 deletions packages/components/src/guide/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ export default function Guide( {
<div className="components-guide__page">
{ pages[ currentPage ].image }

<PageControl
currentPage={ currentPage }
numberOfPages={ pages.length }
setCurrentPage={ setCurrentPage }
/>
{ pages.length > 1 && (
<PageControl
currentPage={ currentPage }
numberOfPages={ pages.length }
setCurrentPage={ setCurrentPage }
/>
) }

{ pages[ currentPage ].content }

Expand Down
4 changes: 3 additions & 1 deletion packages/components/src/guide/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,18 @@
}

&__page-control {
margin: $grid-unit-10 0 $grid-unit-10 0;
margin: 0;
text-align: center;

li {
display: inline-block;
margin: 0;
}

.components-button {
height: 30px;
min-width: 20px;
margin: -6px 0;
}
}

Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/guide/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ describe( 'Guide', () => {
).toHaveLength( 1 );
} );

it( "doesn't display the page control if there is only one page", () => {
const wrapper = shallow(
<Guide pages={ [ { content: <p>Page 1</p> } ] } />
);
expect( wrapper.find( PageControl ).exists() ).toBeFalsy();
} );

it( 'calls onFinish when the finish button is clicked', () => {
const onFinish = jest.fn();
const wrapper = shallow(
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-post/src/components/welcome-guide/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
&__image {
background: #00a0d2;
height: 240px;
margin: 0 0 $grid-unit-20;

&__prm-r {
display: none;
Expand All @@ -26,7 +27,7 @@
font-family: $default-font;
font-size: 24px;
line-height: 1.4;
margin: 0 0 $grid-unit-20 0;
margin: $grid-unit-20 0 $grid-unit-20 0;
padding: 0 $grid-unit-40;
}

Expand Down