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

fix backgroundColour set for deep-landscape #42

Merged
merged 2 commits into from
Mar 7, 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
2 changes: 2 additions & 0 deletions src/lib/get-topper-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ const useEditoriallySelectedTopper = (content) => {
content.topper.backgroundBox === 'light' ? 'white' : 'black';
} else if (!hasDarkBackground(content.topper.backgroundColour)) {
backgroundColour = 'white';
} else {
backgroundColour = 'black';
}
} else if (
content.topper.backgroundColour === 'pink' ||
Expand Down
15 changes: 15 additions & 0 deletions test/lib/get-topper-settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,21 @@ describe('Get topper settings', () => {
expect(topper.backgroundColour).to.equal('white');
});

it('sets the `backgroundColour` to `black` if layout is deep landscape and background is dark', () => {
const topper = getTopperSettings({
topper: { layout: 'deep-landscape', backgroundColour: 'slate' }
});

expect(topper.backgroundColour).to.equal('black');
});
it('sets the `backgroundColour` to `white` if layout is deep landscape and background is undefined', () => {
const topper = getTopperSettings({
topper: { layout: 'deep-landscape' }
});

expect(topper.backgroundColour).to.equal('white');
});

describe('When a background Box is present', () => {
it('sets the `backgroundColour` to `white` if layout is deep landscape and background Box is light', () => {
const topper = getTopperSettings({
Expand Down