Commit 08012582 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '216797-style-toastui-menus' into 'master'

Style ToastUI contextual menus

See merge request gitlab-org/gitlab!33719
parents c4bff0ef bcc57447
...@@ -22,10 +22,9 @@ export const generateToolbarItem = config => { ...@@ -22,10 +22,9 @@ export const generateToolbarItem = config => {
return { return {
type: 'button', type: 'button',
options: { options: {
el: buildWrapper({ props: { icon }, class: classes }), el: buildWrapper({ props: { icon, tooltip }, class: classes }),
event, event,
command, command,
tooltip,
}, },
}; };
}; };
......
<script> <script>
import { GlIcon } from '@gitlab/ui'; import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
export default { export default {
components: { components: {
GlIcon, GlIcon,
}, },
directives: {
GlTooltip: GlTooltipDirective,
},
props: { props: {
icon: { icon: {
type: String, type: String,
required: true, required: true,
}, },
tooltip: {
type: String,
required: true,
},
}, },
}; };
</script> </script>
<template> <template>
<button class="p-0 gl-display-flex toolbar-button"> <button v-gl-tooltip="{ title: tooltip }" class="p-0 gl-display-flex toolbar-button">
<gl-icon class="gl-mx-auto" :name="icon" /> <gl-icon class="gl-mx-auto gl-align-self-center" :name="icon" />
</button> </button>
</template> </template>
// Overrides styles from ToastUI editor /**
* Overrides styles from ToastUI editor
*/
// Toolbar buttons
.tui-editor-defaultUI-toolbar .toolbar-button { .tui-editor-defaultUI-toolbar .toolbar-button {
color: $gl-gray-600; color: $gl-gray-600;
border: 0; border: 0;
...@@ -9,3 +13,19 @@ ...@@ -9,3 +13,19 @@
border: 0; border: 0;
} }
} }
// Contextual menu's & popups
.tui-editor-defaultUI .tui-popup-wrapper {
@include gl-overflow-hidden;
@include gl-rounded-base;
@include gl-border-gray-400;
hr {
@include gl-m-0;
@include gl-bg-gray-400;
}
button {
@include gl-text-gray-800;
}
}
---
title: Style ToastUI contextual menus
merge_request: 33719
author:
type: changed
...@@ -29,10 +29,6 @@ describe('Editor Service', () => { ...@@ -29,10 +29,6 @@ describe('Editor Service', () => {
expect(generatedItem.options.command).toBe(config.command); expect(generatedItem.options.command).toBe(config.command);
}); });
it('generates the correct tooltip', () => {
expect(generatedItem.options.tooltip).toBe(config.tooltip);
});
it('generates the correct event', () => { it('generates the correct event', () => {
expect(generatedItem.options.event).toBe(config.event); expect(generatedItem.options.event).toBe(config.event);
}); });
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import { GlIcon } from '@gitlab/ui'; import { GlIcon } from '@gitlab/ui';
import ToolbarItem from '~/vue_shared/components/rich_content_editor/toolbar_item.vue'; import ToolbarItem from '~/vue_shared/components/rich_content_editor/toolbar_item.vue';
...@@ -9,33 +10,45 @@ describe('Toolbar Item', () => { ...@@ -9,33 +10,45 @@ describe('Toolbar Item', () => {
const findButton = () => wrapper.find('button'); const findButton = () => wrapper.find('button');
const buildWrapper = propsData => { const buildWrapper = propsData => {
wrapper = shallowMount(ToolbarItem, { propsData }); wrapper = shallowMount(ToolbarItem, {
propsData,
directives: {
GlTooltip: createMockDirective(),
},
});
}; };
describe.each` describe.each`
icon icon | tooltip
${'heading'} ${'heading'} | ${'Headings'}
${'bold'} ${'bold'} | ${'Add bold text'}
${'italic'} ${'italic'} | ${'Add italic text'}
${'strikethrough'} ${'strikethrough'} | ${'Add strikethrough text'}
${'quote'} ${'quote'} | ${'Insert a quote'}
${'link'} ${'link'} | ${'Add a link'}
${'doc-code'} ${'doc-code'} | ${'Insert a code block'}
${'list-bulleted'} ${'list-bulleted'} | ${'Add a bullet list'}
${'list-numbered'} ${'list-numbered'} | ${'Add a numbered list'}
${'list-task'} ${'list-task'} | ${'Add a task list'}
${'list-indent'} ${'list-indent'} | ${'Indent'}
${'list-outdent'} ${'list-outdent'} | ${'Outdent'}
${'dash'} ${'dash'} | ${'Add a line'}
${'table'} ${'table'} | ${'Add a table'}
${'code'} ${'code'} | ${'Insert an image'}
`('toolbar item component', ({ icon }) => { ${'code'} | ${'Insert inline code'}
beforeEach(() => buildWrapper({ icon })); `('toolbar item component', ({ icon, tooltip }) => {
beforeEach(() => buildWrapper({ icon, tooltip }));
it('renders a toolbar button', () => { it('renders a toolbar button', () => {
expect(findButton().exists()).toBe(true); expect(findButton().exists()).toBe(true);
}); });
it('renders the correct tooltip', () => {
const buttonTooltip = getBinding(wrapper.element, 'gl-tooltip');
expect(buttonTooltip).toBeDefined();
expect(buttonTooltip.value.title).toBe(tooltip);
});
it(`renders the ${icon} icon`, () => { it(`renders the ${icon} icon`, () => {
expect(findIcon().exists()).toBe(true); expect(findIcon().exists()).toBe(true);
expect(findIcon().props().name).toBe(icon); expect(findIcon().props().name).toBe(icon);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment