Skip to content

Commit

Permalink
Restore BEM conventions to versioned indicator, removing specificity …
Browse files Browse the repository at this point in the history
…nesting
  • Loading branch information
robbieaverill committed Sep 5, 2018
1 parent 9927c9e commit 90ddb5c
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/styles/bundle.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion client/src/components/ElementEditor/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,21 @@ class Header extends Component {
}

let versionStateButtonTitle = '';
const stateClassNames = ['element-editor-header__version-state'];

if (!isPublished) {
versionStateButtonTitle = i18n._t('ElementHeader.STATE_DRAFT', 'Item has not been published yet');
stateClassNames.push('element-editor-header__version-state--draft');
}

if (isPublished && !isLiveVersion) {
versionStateButtonTitle = i18n._t('ElementHeader.STATE_MODIFIED', 'Item has unpublished changes');
stateClassNames.push('element-editor-header__version-state--modified');
}

return (
<span
className="element-editor-header__version-state"
className={classNames(stateClassNames)}
title={versionStateButtonTitle}
/>
);
Expand Down
10 changes: 2 additions & 8 deletions client/src/components/ElementEditor/Header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,12 @@
position: relative;
width: 8px;
z-index: 1;
}

.element-editor__element {
&--draft {
.element-editor-header__version-state {
background-color: $state-draft-bg;
}
background-color: $state-draft-bg;
}

&--modified {
.element-editor-header__version-state {
background-color: $state-modified-bg;
}
background-color: $state-modified-bg;
}
}
10 changes: 6 additions & 4 deletions client/src/components/ElementEditor/tests/Header-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ describe('Header', () => {
/>
);

expect(wrapper.find('.element-editor-header__version-state').prop('title'))
.toContain('not been published');
const versionedState = wrapper.find('.element-editor-header__version-state');
expect(versionedState.prop('title')).toContain('not been published');
expect(versionedState.hasClass('element-editor-header__version-state--draft')).toBe(true);
});

it('identifies modified versions', () => {
Expand All @@ -148,8 +149,9 @@ describe('Header', () => {
/>
);

expect(wrapper.find('.element-editor-header__version-state').prop('title'))
.toContain('has unpublished changes');
const versionedState = wrapper.find('.element-editor-header__version-state');
expect(versionedState.prop('title')).toContain('has unpublished changes');
expect(versionedState.hasClass('element-editor-header__version-state--modified')).toBe(true);
});

it('ignores live versions', () => {
Expand Down
3 changes: 2 additions & 1 deletion client/src/styles/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
}

// Legacy - tweaks to put the version indicator in the right place for PHP
// GridField rendering
// GridField rendering. Specificity is deliberate so it doesn't affect the React
// elemental area editor
.elemental-report__grid-field {
.element-editor-header__version-state {
bottom: 9px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<% end_if %>

<% if $IsVersioned && $VersionState %>
<span class="element-editor__element--{$VersionState}">
<span class="element-editor-header__version-state" title="$VersionStateTitle"></span>
</span>
<span
class="element-editor-header__version-state element-editor-header__version-state--{$VersionState}"
title="$VersionStateTitle"
/>
<% end_if %>

0 comments on commit 90ddb5c

Please sign in to comment.