type.name === 'SbAvatar')
},
diff --git a/src/components/Button/SbButton.vue b/src/components/Button/SbButton.vue
index 8f65f5088..68c1043b7 100644
--- a/src/components/Button/SbButton.vue
+++ b/src/components/Button/SbButton.vue
@@ -85,6 +85,10 @@ export default {
type: Boolean,
default: false,
},
+ isBorderless: {
+ type: Boolean,
+ default: false,
+ },
label: {
type: String,
default: null,
@@ -105,6 +109,7 @@ export default {
`sb-button--${this.variant}`,
{
'sb-button--disabled': this.isDisabled,
+ 'sb-button--borderless': this.isBorderless,
'sb-button--small': this.size === 'small',
'sb-button--large': this.size === 'large',
'sb-button--full': this.isFullWidth,
diff --git a/src/components/Button/button.scss b/src/components/Button/button.scss
index 73cb39a39..4a2a0e6b4 100644
--- a/src/components/Button/button.scss
+++ b/src/components/Button/button.scss
@@ -215,6 +215,10 @@
}
}
+.sb-button--borderless {
+ border: 0;
+}
+
// button elements
.sb-button__label {
diff --git a/src/components/EditorHeader/EditorHeader.stories.js b/src/components/EditorHeader/EditorHeader.stories.js
index 79042fced..c5c131349 100644
--- a/src/components/EditorHeader/EditorHeader.stories.js
+++ b/src/components/EditorHeader/EditorHeader.stories.js
@@ -1,6 +1,15 @@
import { SbEditorHeader } from './index'
-const languagesItems = ['English', 'German']
+const languages = [
+ {
+ name: 'English',
+ code: 'en',
+ },
+ {
+ name: 'Portuguese',
+ code: 'pt',
+ },
+]
const usersList = [
{
@@ -17,7 +26,7 @@ const usersList = [
},
]
-const optionsList = [
+const actionsList = [
{
name: 'Open Draft',
},
@@ -36,118 +45,69 @@ const optionsList = [
},
]
-const actionsList = [
- {
- name: 'Dimensions',
- },
- {
- name: 'Preview',
- },
- {
- name: 'Unpublish',
- },
-]
-
-const EditorTemplate = (args) => ({
- components: { SbEditorHeader },
- setup() {
- return { args }
- },
- template: `
-
- `,
-})
-
export default {
title: 'Interface/SbEditorHeader',
component: SbEditorHeader,
parameters: {
docs: {
description: {
- component: 'SbEditorHeader',
+ component: 'Header component for various editors',
},
},
},
args: {
- languages: [...languagesItems],
+ languages: [...languages],
users: [...usersList],
actions: [...actionsList],
- options: [...optionsList],
- spaceStatus: 'unpublished',
hasSaveButton: true,
- showPublishedIcon: true,
- headerTitle: 'API-based & Headless CMS as a Service',
- headerSubTitle: 'Updated 15m ago',
+ headerTitle: 'Headless CMS',
+ headerSubtitle: 'Updated 15m ago',
+ mode: 'light',
},
argTypes: {
- languages: {
- name: 'languages',
- description: 'Available languages array',
- control: {
- type: 'array',
- },
- },
- users: {
- name: 'users',
- description: 'User information array',
- control: {
- type: 'object',
- },
- },
- actions: {
- name: 'actions',
- description: 'Available actions array',
- control: {
- type: 'object',
- },
- },
- options: {
- name: 'options',
- description: 'Available options array',
- control: {
- type: 'object',
- },
- },
- spaceStatus: {
- name: 'spaceStatus',
- description:
- 'Change the icon to inform whether the space is published or not',
- options: ['unpublished', 'published', 'published-and-changes'],
- control: {
- type: 'select',
- },
- },
- hasSaveButton: {
- name: 'hasSaveButton',
- description: 'Props to show the save icon',
- control: {
- type: 'boolean',
- },
- },
- showPublishedIcon: {
- name: 'showPublishedIcon',
- description: 'Props to show or not the published icon',
- control: {
- type: 'boolean',
- },
- },
- headerTitle: {
- name: 'headerTitle',
- description: '',
- control: {
- type: 'text',
- },
- },
- headerSubTitle: {
- name: 'headerSubTitle',
- description: '',
- control: {
- type: 'text',
- },
+ mode: {
+ options: ['light', 'dark'],
+ control: { type: 'radio' },
},
},
}
-export const Default = EditorTemplate.bind({})
+export const Default = {
+ name: 'Default',
+ render: (args, { argTypes }) => ({
+ components: { SbEditorHeader },
+ props: Object.keys(argTypes),
+ template: `
+
+ `,
+ }),
+}
+
+export const WithSlots = () => ({
+ components: { SbEditorHeader },
+ template: `
+
+
+ Custom left slot
+
+
+
+ Custom center slot
+
+
+
+ Custom right slot
+
+
+ `,
+})
+
+export const DarkMode = () => ({
+ components: { SbEditorHeader },
+ template: `
+
+ `,
+})
diff --git a/src/components/EditorHeader/EditorHeader.vue b/src/components/EditorHeader/EditorHeader.vue
index e5e161c1c..926a10dbe 100644
--- a/src/components/EditorHeader/EditorHeader.vue
+++ b/src/components/EditorHeader/EditorHeader.vue
@@ -1,106 +1,26 @@
-
-
-
-
+
diff --git a/src/components/EditorHeader/__tests__/DesktopAndTabletViewer.spec.js b/src/components/EditorHeader/__tests__/DesktopAndTabletViewer.spec.js
deleted file mode 100644
index bc67883d3..000000000
--- a/src/components/EditorHeader/__tests__/DesktopAndTabletViewer.spec.js
+++ /dev/null
@@ -1,102 +0,0 @@
-import { SbDesktopAndTabletViewer, SbHeaderItem } from '..'
-import SbAvatar from '../../Avatar'
-import { SbMenu, SbMenuItem } from '../../Menu'
-import SbIcon from '../../Icon'
-import SbTooltip from '../../Tooltip'
-
-import { mount } from '@vue/test-utils'
-
-const factory = (props) => {
- return mount(SbDesktopAndTabletViewer, {
- props,
- })
-}
-
-const actionsList = [
- {
- name: 'dimensions',
- },
- {
- name: 'preview',
- },
- {
- name: 'unpublish',
- },
-]
-
-const usersList = [
- {
- src: 'https://avatars0.githubusercontent.com/u/20342656?s=460&u=1f62c95c10543861ad74b58a3c03cd774e7a4fa4&v=4',
- name: 'John Doe',
- },
- {
- src: 'https://avatars0.githubusercontent.com/u/20342656?s=460&u=1f62c95c10543861ad74b58a3c03cd774e7a4fa4&v=4',
- name: 'Kobe Bryant',
- },
-]
-
-const fakeProps = {
- languages: ['English', 'German'],
- users: [...usersList],
- actions: [...actionsList],
- format: 'desktop',
- size: 1200,
- headerTitle: 'A awesome cms',
- headerSubTitle: 'Its true',
-}
-
-describe.skip('SbDesktopAndTabletViewer component', () => {
- it('should render all internal components', () => {
- const wrapper = factory(fakeProps)
-
- expect(wrapper.findComponent(SbHeaderItem).exists()).toBe(true)
-
- expect(wrapper.findAllComponents(SbHeaderItem).length).toBe(5)
-
- expect(wrapper.findComponent(SbAvatar).exists()).toBe(true)
-
- expect(wrapper.findAllComponents(SbAvatar).length).toBe(2)
-
- expect(wrapper.findComponent(SbMenu).exists()).toBe(true)
-
- expect(wrapper.findAllComponents(SbMenuItem).length).toBe(2)
-
- expect(wrapper.findComponent(SbTooltip).exists()).toBe(true)
-
- expect(wrapper.findAllComponents(SbTooltip).length).toBe(5)
-
- expect(wrapper.findComponent(SbIcon).exists()).toBe(true)
-
- expect(wrapper.findAllComponents(SbIcon).length).toBe(6)
- })
-
- it('should trigger all functions', () => {
- const wrapper = factory(fakeProps)
-
- wrapper.vm.handleSetNewLanguage = vi.fn()
-
- wrapper.vm.handleSelectNewAction = vi.fn()
-
- wrapper.vm.handleSetNewLanguage()
-
- expect(wrapper.vm.handleSetNewLanguage).toBeCalled()
-
- wrapper.vm.handleSelectNewAction()
-
- expect(wrapper.vm.handleSelectNewAction).toBeCalled()
- })
-
- it('should emit all internal events', async () => {
- const wrapper = factory(fakeProps)
-
- wrapper.vm.$emit('changes', { type: 'act', action: 'unpublish' })
-
- await wrapper.vm.$nextTick()
-
- expect(wrapper.emitted('changes')).toBeTruthy()
-
- expect(wrapper.emitted('changes')).toEqual([
- [{ type: 'act', action: 'unpublish' }],
- ])
- })
-})
diff --git a/src/components/EditorHeader/__tests__/EditorHeader.spec.js b/src/components/EditorHeader/__tests__/EditorHeader.spec.js
index 1da6a0791..cb3a50275 100644
--- a/src/components/EditorHeader/__tests__/EditorHeader.spec.js
+++ b/src/components/EditorHeader/__tests__/EditorHeader.spec.js
@@ -1,10 +1,4 @@
-import {
- SbEditorHeader,
- SbHeaderTitle,
- SbHeaderItem,
- SbMobileViewer,
- SbDesktopAndTabletViewer,
-} from '../index'
+import { SbEditorHeader, SbHeaderTitle, SbHeaderItem } from '../index'
import SbIcon from '../../Icon'
import SbButton from '../../Button'
@@ -30,25 +24,6 @@ const usersList = [
},
]
-const optionsList = [
- {
- name: 'Open Draft',
- },
- {
- name: 'Open Published',
- },
- {
- name: 'Draft json',
- },
- {
- name: 'Published json',
- },
- {
- name: 'Unpublish',
- type: 'negative',
- },
-]
-
const actionsList = [
{
name: 'dimensions',
@@ -65,33 +40,30 @@ const fakeProps = {
languages: ['English', 'German'],
users: [...usersList],
actions: [...actionsList],
- options: [...optionsList],
spaceStatus: 'unpublished',
hasSaveButton: true,
showPublishedIcon: true,
- headerTitle: 'A awesome CMS',
- headerSubTitle: 'Its true',
+ headerTitle: 'An awesome CMS',
+ headerSubtitle: 'Its true',
}
-describe.skip('SbEditorHeader component', () => {
+describe('SbEditorHeader component', () => {
it('should render all internal components', () => {
const wrapper = factory(fakeProps)
expect(wrapper.findComponent(SbHeaderTitle).exists()).toBe(true)
- expect(wrapper.findComponent(SbHeaderTitle).text()).toBe('')
+ expect(wrapper.findComponent(SbHeaderTitle).text()).toBe(
+ 'An awesome CMSIts true'
+ )
expect(wrapper.findComponent(SbHeaderItem).exists()).toBe(true)
- expect(wrapper.findAllComponents(SbHeaderItem).length).toBe(9)
-
- expect(wrapper.findComponent(SbDesktopAndTabletViewer).exists()).toBe(true)
-
- expect(wrapper.findComponent(SbMobileViewer).exists()).toBe(false)
+ expect(wrapper.findAllComponents(SbHeaderItem).length).toBe(7)
expect(wrapper.findComponent(SbIcon).exists()).toBe(true)
- expect(wrapper.findAllComponents(SbIcon).length).toBe(8)
+ expect(wrapper.findAllComponents(SbIcon).length).toBe(9)
expect(wrapper.findComponent(SbButton).exists()).toBe(true)
@@ -105,7 +77,7 @@ describe.skip('SbEditorHeader component', () => {
expect(wrapper.findAllComponents(SbMenuList).length).toBe(2)
- expect(wrapper.findAllComponents(SbMenuItem).length).toBe(7)
+ expect(wrapper.findAllComponents(SbMenuItem).length).toBe(5)
})
it('should emit all internal events', async () => {
@@ -125,15 +97,6 @@ describe.skip('SbEditorHeader component', () => {
expect(wrapper.emitted('publish')).toBeTruthy()
- // select-options event
- wrapper.vm.$emit('select-options', 'unpublished')
-
- await wrapper.vm.$nextTick()
-
- expect(wrapper.emitted('select-options')).toBeTruthy()
-
- expect(wrapper.emitted('select-options')).toEqual([['unpublished']])
-
// select-action event
wrapper.vm.$emit('select-action', 'unpublished')
diff --git a/src/components/EditorHeader/__tests__/HeaderTitle.spec.js b/src/components/EditorHeader/__tests__/HeaderTitle.spec.js
index 23c508ea8..c16d406f6 100644
--- a/src/components/EditorHeader/__tests__/HeaderTitle.spec.js
+++ b/src/components/EditorHeader/__tests__/HeaderTitle.spec.js
@@ -9,16 +9,16 @@ const factory = (props) => {
})
}
-describe.skip('Test if Header title renderer correctly', () => {
+describe('Test if Header title renderer correctly', () => {
it('Test to check if the component renders the text', () => {
const wrapper = factory({
- title: 'Awesome cms',
- format: 'mobile',
+ headerTitle: 'Awesome cms',
+ headerSubtitle: 'Its true',
})
- expect(wrapper.find('div').classes('sb-editor--title')).toBe(true)
+ expect(wrapper.find('div').classes('sb-editor-header__title')).toBe(true)
- expect(wrapper.find('div').text()).toBe('Awesome cms')
+ expect(wrapper.find('div').text()).toBe('Awesome cmsIts true')
expect(wrapper.findComponent(SbButton).exists()).toBe(true)
})
diff --git a/src/components/EditorHeader/__tests__/MobileViewer.spec.js b/src/components/EditorHeader/__tests__/MobileViewer.spec.js
deleted file mode 100644
index d833b9ef0..000000000
--- a/src/components/EditorHeader/__tests__/MobileViewer.spec.js
+++ /dev/null
@@ -1,74 +0,0 @@
-import MobileViewer from '../components/MobileViewer'
-import SbHeaderItem from '../components/HeaderItem'
-import SbAvatar from '../../Avatar'
-import { SbMenuItem } from '../../Menu'
-import SbIcon from '../../Icon'
-
-import { mount } from '@vue/test-utils'
-
-const actionsList = [
- {
- name: 'dimensions',
- },
- {
- name: 'preview',
- },
- {
- name: 'unpublish',
- },
-]
-
-const usersList = [
- {
- src: 'https://avatars0.githubusercontent.com/u/20342656?s=460&u=1f62c95c10543861ad74b58a3c03cd774e7a4fa4&v=4',
- name: 'John Doe',
- },
- {
- src: 'https://avatars0.githubusercontent.com/u/20342656?s=460&u=1f62c95c10543861ad74b58a3c03cd774e7a4fa4&v=4',
- name: 'Kobe Bryant',
- },
-]
-
-const fakeProps = {
- languages: ['English', 'German'],
- users: [...usersList],
- actions: [...actionsList],
- format: 'mobile',
- size: 320,
-}
-
-const factory = (props) => {
- return mount(MobileViewer, {
- props,
- })
-}
-
-describe.skip('MobileViewer component test', () => {
- const wrapper = factory(fakeProps)
-
- it('should render with all components', () => {
- expect(wrapper.findComponent(SbHeaderItem).exists()).toBe(true)
-
- expect(wrapper.findAllComponents(SbMenuItem).length).toBe(7)
-
- expect(wrapper.findAllComponents(SbAvatar).length).toBe(2)
-
- expect(wrapper.findComponent(SbIcon).exists()).toBe(true)
- })
-
- it('should render all texts passed by props', () => {
- const arrayWithAssertionsTexts = [
- 'dimensions',
- 'preview',
- 'unpublish',
- 'English',
- 'German',
- 'John Doe',
- 'Kobe Bryant',
- ]
-
- wrapper.findAllComponents(SbMenuItem).wrappers.forEach((wrapper, index) => {
- expect(wrapper.text()).toBe(arrayWithAssertionsTexts[index])
- })
- })
-})
diff --git a/src/components/EditorHeader/components/DesktopAndTabletViewer.vue b/src/components/EditorHeader/components/HeaderActions.vue
similarity index 61%
rename from src/components/EditorHeader/components/DesktopAndTabletViewer.vue
rename to src/components/EditorHeader/components/HeaderActions.vue
index 4375891d6..93c0aa0f7 100644
--- a/src/components/EditorHeader/components/DesktopAndTabletViewer.vue
+++ b/src/components/EditorHeader/components/HeaderActions.vue
@@ -1,66 +1,65 @@
-