diff --git a/changelog/unreleased/enhancement-add-contextual-helper-component b/changelog/unreleased/enhancement-add-contextual-helper-component new file mode 100644 index 000000000..4a444179a --- /dev/null +++ b/changelog/unreleased/enhancement-add-contextual-helper-component @@ -0,0 +1,7 @@ +Enhancement: Add OcContextualHelper + +We've added a contextual helper component to provide more information +based on the context + +https://github.com/owncloud/web/issues/6590 +https://github.com/owncloud/owncloud-design-system/pull/2064 \ No newline at end of file diff --git a/src/components/atoms/OcButton/OcButton.vue b/src/components/atoms/OcButton/OcButton.vue index a7fa0c6e6..420d234d9 100644 --- a/src/components/atoms/OcButton/OcButton.vue +++ b/src/components/atoms/OcButton/OcButton.vue @@ -56,6 +56,17 @@ export default { type: String, default: null, }, + /** + * When setting the button’s type to a link, use this option to give a give a target. + * `_blank, _self, _parent, _top` + */ + target: { + type: String, + default: null, + validator: value => { + return value.match(/(_blank|_self|_parent|_top)/) + }, + }, /** * When setting the button’s type to a router-link, use this option to give a to. */ @@ -144,6 +155,7 @@ export default { additionalAttributes() { return { ...(this.href && { href: this.href }), + ...(this.target && { target: this.target }), ...(this.to && { to: this.to }), ...(this.type === "button" && { type: this.submit }), } diff --git a/src/components/atoms/OcContextualHelper/OcContextualHelper.spec.js b/src/components/atoms/OcContextualHelper/OcContextualHelper.spec.js new file mode 100644 index 000000000..ccab8e528 --- /dev/null +++ b/src/components/atoms/OcContextualHelper/OcContextualHelper.spec.js @@ -0,0 +1,45 @@ +import OcContextualHelper from "./OcContextualHelper.vue" +import { createLocalVue, shallowMount } from "@vue/test-utils" +import GetTextPlugin from "vue-gettext" + +const localVue = createLocalVue() +localVue.use(GetTextPlugin, { + translations: "does-not-matter.json", + silent: true, +}) + +describe("OcContextualHelper", () => { + function getWrapperWithProps(props) { + return shallowMount(OcContextualHelper, { + localVue: localVue, + propsData: props, + stubs: { + OcDrop: true, + }, + }) + } + describe("should use props correctly", () => { + it("should set text prop", () => { + const wrapper = getWrapperWithProps({ text: "test-my-text" }) + expect(wrapper.find(".info-text").text()).toBe("test-my-text") + }) + it("should set list prop", async () => { + const listValues = ["a-list-value", "b-list-value", "c-list-value"] + const wrapper = getWrapperWithProps({ list: listValues }) + const result = wrapper.find(".info-list").text() + listValues.forEach(value => { + expect(result).toContain(value) + }) + }) + it("should set a readMore link", async () => { + const wrapper = getWrapperWithProps({ readMoreLink: "owncloud.design" }) + const attributes = wrapper.find(".info-more-link").attributes() + expect(attributes["href"]).toBe("owncloud.design") + expect(attributes["target"]).toBe("_blank") + }) + it("should set end-text prop", async () => { + const wrapper = getWrapperWithProps({ endText: "test-my-text" }) + expect(wrapper.find(".info-text-end").text()).toBe("test-my-text") + }) + }) +}) diff --git a/src/components/atoms/OcContextualHelper/OcContextualHelper.vue b/src/components/atoms/OcContextualHelper/OcContextualHelper.vue new file mode 100644 index 000000000..167942ad8 --- /dev/null +++ b/src/components/atoms/OcContextualHelper/OcContextualHelper.vue @@ -0,0 +1,138 @@ + + + + + + + +## Examples +A simple example, using only text. +```js + + +``` + +An example using Text, List, End-Text and Read-More-Link properties. +```js + + +``` + diff --git a/src/tokens/ods/font.yaml b/src/tokens/ods/font.yaml index cb2c7f322..70ed036c9 100644 --- a/src/tokens/ods/font.yaml +++ b/src/tokens/ods/font.yaml @@ -3,6 +3,8 @@ font: size: default: value: 1rem + small: + value: 0.88rem medium: value: 1.25rem large: