Skip to content

Commit

Permalink
V2 4 rc 0 (#430)
Browse files Browse the repository at this point in the history
* chore: header-panel click prevent
 - @carbon/[email protected]
 - [email protected]
  • Loading branch information
lee-chase authored Jun 4, 2019
1 parent dbf68d3 commit 03228da
Show file tree
Hide file tree
Showing 23 changed files with 394 additions and 96 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@carbon/vue",
"description": "A collection of components for the Carbon Design System built using Vue.js",
"version": "2.3.0",
"version": "2.5.0-rc.0",
"license": "Apache-2.0",
"repository": {
"type": "git",
Expand Down Expand Up @@ -62,8 +62,8 @@
},
"sideEffects": true,
"dependencies": {
"@carbon/icons-vue": "^10.2.0",
"carbon-components": "^10.2.0",
"@carbon/icons-vue": "10.3.0-rc.2",
"carbon-components": "10.3.0-rc.2",
"flatpickr": "4.5.7",
"vue": "^2.6.10"
},
Expand Down
19 changes: 0 additions & 19 deletions packages/core/src/components/cv-header/cv-header-global-action.vue

This file was deleted.

21 changes: 0 additions & 21 deletions packages/core/src/components/cv-header/cv-header.vue

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<template>
<button
v-on="$listeners"
class="cv-header-global-action bx--header__action"
:class="dataActive ? 'bx--header__action--active' : ''"
type="button"
aria-haspopup="true"
:aria-controls="ariaControls"
:aria-expanded="active"
@click="gaToggle"
@focusout="gaFocusout"
>
<slot />
</button>
</template>

<script>
import uidMixin from '../../mixins/uid-mixin';
export default {
name: 'CvHeaderGlobalAction',
mixins: [uidMixin],
props: {
active: Boolean,
ariaControls: { type: String, required: true },
},
mounted() {
this.$parent.$emit('cv:panel-control-mounted', this);
},
beforeDestroy() {
this.$parent.$emit('cv:panel-control-beforeDestroy', this);
},
data() {
return {
dataActive: this.active,
};
},
watch: {
expanded() {
if (this.active !== this.dataActive) {
this.gaToggle();
}
},
},
computed: {
internalActive: {
get() {
return this.dataActive;
},
set(val) {
// do not emit 'cv:panel-control-toggle'
this.dataActive = val;
},
},
},
methods: {
gaToggle() {
this.$el.focus();
this.$parent.$emit('cv:panel-control-toggle', this);
},
gaFocusout(ev) {
this.$parent.$emit('cv:panel-control-focusout', this, ev);
},
},
};
</script>
61 changes: 61 additions & 0 deletions packages/core/src/components/cv-ui-shell/cv-header-panel.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<template>
<div
class="cv-header-panel bx--header-panel"
:class="{ 'bx--header-panel--expanded': internalExpanded }"
:hidden="!internalExpanded"
@focusout="onFocusout"
@mousedown="onMouseDown"
>
<slot></slot>
</div>
</template>

<script>
export default {
name: 'CvHeaderPanel',
props: {
expanded: Boolean,
id: { type: String, required: true },
},
mounted() {
this.$parent.$emit('cv:panel-mounted', this);
},
beforeDestroy() {
this.$parent.$emit('cv:panel-beforeDestroy', this);
},
data() {
return {
dataExpanded: this.expanded,
};
},
watch: {
expanded() {
this.dataExpanded = this.expanded;
this.$parent.$emit('cv:panel-resize', this);
},
},
computed: {
internalExpanded: {
get() {
return this.dataExpanded;
},
set(val) {
// Do not emit cv:panel-resize
this.dataExpanded = val;
},
},
},
methods: {
onFocusout(ev) {
this.$parent.$emit('cv:panel-focusout', this, ev);
},
onMouseDown(ev) {
if (this.$el.contains(ev.target)) {
ev.preventDefault();
}
},
},
};
</script>

<style lang="scss"></style>
92 changes: 92 additions & 0 deletions packages/core/src/components/cv-ui-shell/cv-header.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<template>
<header class="cv-header bx--header" role="banner" data-header>
<slot />
<div v-if="$slots['header-global']" class="bx--header__global">
<slot name="header-global" />
</div>
<slot name="right-panels" />
</header>
</template>

<script>
export default {
name: 'CvHeader',
created() {
// add these on created otherwise cv:mounted is too late.
this.$on('cv:panel-control-mounted', this.onCvPanelControlMounted);
this.$on('cv:panel-control-beforeDestroy', this.onCvPanelControlBeforeDestroy);
this.$on('cv:panel-control-toggle', this.onCvPanelControlToggle);
this.$on('cv:panel-control-focusout', this.onCvPanelControlFocusout);
this.$on('cv:panel-mounted', this.onCvPanelMounted);
this.$on('cv:panel-beforeDestroy', this.onCvPanelBeforeDestroy);
this.$on('cv:panel-focusout', this.onCvPanelFocusout);
},
mounted() {
console.warn(
`${
this.$vnode.componentOptions.Ctor.extendOptions.name
} - Under review. This component isn't quite ready. Hopefully no features will get broken but this cannot be guarenteed.`
);
},
data() {
return {
panelControllers: [],
panels: [],
};
},
methods: {
onCvPanelControlMounted(srcComponent) {
this.panelControllers.push(srcComponent);
},
onCvPanelControlBeforeDestroy(srcComponent) {
const index = this.panelControllers.findIndex(item => item.id === srcComponent.id);
if (index > -1) {
this.panelControllers.splice(index, 1);
}
},
onCvPanelControlToggle(srcComponent, force) {
const foundIndex = this.panels.findIndex(item => item.id === srcComponent.ariaControls);
if (foundIndex > -1) {
const newValue = force !== undefined ? force : !srcComponent.internalActive;
for (let index in this.panels) {
this.panels[index].internalExpanded = false;
}
for (let index in this.panelControllers) {
this.panelControllers[index].internalActive = false;
}
srcComponent.internalActive = newValue;
this.panels[foundIndex].internalExpanded = newValue;
}
},
onCvPanelControlFocusout(srcComponent, srcEvent) {
const found = this.panels.find(item => item.id === srcComponent.ariaControls);
if (found && found.$el !== srcEvent.relatedTarget && !found.$el.contains(srcEvent.relatedTarget)) {
this.onCvPanelControlToggle(srcComponent, false);
}
},
onCvPanelMounted(srcComponent) {
this.panels.push(srcComponent);
},
onCvPanelBeforeDestroy(srcComponent) {
const index = this.panels.findIndex(item => item.id === srcComponent.id);
if (index > -1) {
this.panels.splice(index, 1);
}
},
onCvPanelFocusout(srcComponent, srcEvent) {
const found = this.panelControllers.find(item => item.ariaControls === srcComponent.id);
if (
srcComponent.$el !== srcEvent.relatedTarget &&
!srcComponent.$el.contains(srcEvent.relatedTarget) &&
found &&
found.$el !== srcEvent.relatedTarget
) {
this.onCvPanelControlToggle(found, false);
}
},
},
};
</script>
16 changes: 16 additions & 0 deletions packages/core/src/components/cv-ui-shell/cv-switcher-item-link.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<a class="cv-switcher-item-link bx--switcher__item-link" :class="{ 'bx--switcher__item-link--selected': selected }">
<slot />
</a>
</template>

<script>
export default {
name: 'CvSwitcherItemLink',
props: {
selected: Boolean,
},
};
</script>

<style lang="scss"></style>
13 changes: 13 additions & 0 deletions packages/core/src/components/cv-ui-shell/cv-switcher-item.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template>
<li class="cv-switcher-item bx--switcher__item">
<slot />
</li>
</template>

<script>
export default {
name: 'CvSwitcherItem',
};
</script>

<style lang="scss"></style>
13 changes: 13 additions & 0 deletions packages/core/src/components/cv-ui-shell/cv-switcher.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template>
<ul class="cv-switcher bx--switcher__item">
<slot />
</ul>
</template>

<script>
export default {
name: 'CvSwitcher',
};
</script>

<style lang="scss"></style>
16 changes: 8 additions & 8 deletions packages/core/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
resolved "https://registry.yarnpkg.com/@carbon/icon-helpers/-/icon-helpers-10.2.0.tgz#f58ab1d14b8b63d485d31e7d785d25057eac5409"
integrity sha512-PAxu8KMuSrifF4VCW7N7bgu/QKG/Q4T9ojWUEqI0zKjTCkJnzEZTYgK1FrWAdE1uAdAwLlbPIjzIS/QzP15Uvw==

"@carbon/icons-vue@^10.2.0":
version "10.2.0"
resolved "https://registry.yarnpkg.com/@carbon/icons-vue/-/icons-vue-10.2.0.tgz#0623cabd8d99a80f3c76af35da039742fcdbf3e2"
integrity sha512-haNbmbmA5hejZpaIhxRKojfW9fX56s4Mk6q5h6ZBk0PIvvYw7hxcaKI3+XnKHGLAM/yL+Y083Al8fWPxkBpFKw==
"@carbon/icons-vue@10.3.0-rc.2":
version "10.3.0-rc.2"
resolved "https://registry.yarnpkg.com/@carbon/icons-vue/-/icons-vue-10.3.0-rc.2.tgz#1d0fb8afbfc3c0019960c0ec199257680dac33e9"
integrity sha512-6fWtsyNLc+uC4/IcucO/CvxvPf6ES/QmxbG7QkprdIg9/Oe4GDTjcv1Pj1KTSbnJGLJ25q0LXlKs7TOLtNoINA==
dependencies:
"@carbon/icon-helpers" "10.2.0"

Expand Down Expand Up @@ -1043,10 +1043,10 @@ caniuse-lite@^1.0.30000955, caniuse-lite@^1.0.30000957:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000960.tgz#ec48297037e5607f582f246ae7b12bee66a78999"
integrity sha512-7nK5qs17icQaX6V3/RYrJkOsZyRNnroA4+ZwxaKJzIKy+crIy0Mz5CBlLySd2SNV+4nbUZeqeNfiaEieUBu3aA==

carbon-components@^10.2.0:
version "10.2.0"
resolved "https://registry.yarnpkg.com/carbon-components/-/carbon-components-10.2.0.tgz#a7c3631d31cdbb3e9efe6601f02303e0c704fe45"
integrity sha512-LAtwYD5LvH60kx+Y7VyWAAL66kzrANrclThKMzv+fwLLO3xNZ6mLmEdvuEbPdjnTiRSUdlHajgA+evVu672F1w==
carbon-components@10.3.0-rc.2:
version "10.3.0-rc.2"
resolved "https://registry.yarnpkg.com/carbon-components/-/carbon-components-10.3.0-rc.2.tgz#b3a10eb5fa3b62ef0e2350f32247667e315c41ca"
integrity sha512-8hwIk8ffFKUFr4eTiibgq8CV3H9sV2hKxP2WEcu3Kw2LZmcoC3uA5X57oLnNf39OQYV5RPZzCzc5Lhb3FsKIfQ==
dependencies:
carbon-icons "^7.0.7"
flatpickr "4.5.7"
Expand Down
8 changes: 4 additions & 4 deletions storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "storybook",
"version": "2.3.0",
"version": "2.5.0-rc.0",
"private": true,
"description": "> TODO: description",
"scripts": {
"start": "start-storybook -p 9001 -c .storybook",
"build": "build-storybook"
},
"dependencies": {
"@carbon/icons-vue": "^10.0.0",
"carbon-components": "^10.2.0",
"@carbon/icons-vue": "10.3.0-rc.2",
"carbon-components": "10.3.0-rc.2",
"vue": "^2.6.10"
},
"devDependencies": {
"@babel/core": "^7.4.0",
"@carbon/vue": "^2.3.0",
"@carbon/vue": "^2.5.0-rc.0",
"@storybook/addon-actions": "^5.0.3",
"@storybook/addon-knobs": "^5.0.3",
"@storybook/addon-notes": "^5.0.3",
Expand Down
Loading

0 comments on commit 03228da

Please sign in to comment.