Skip to content

Commit

Permalink
feat: export tooltip consts
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-chase committed Apr 12, 2022
1 parent 6cf54a8 commit 2ca0796
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
2 changes: 2 additions & 0 deletions packages/core/src/components/cv-tooltip/consts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const alignments = ['start', 'center', 'end'];
export const directions = ['top', 'bottom', 'right', 'left'];
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@

<script>
import { uidMixin, carbonPrefixMixin } from '../../mixins';
import { alignments, directions } from './consts';
export default {
name: 'CvDefinitionTooltip',
mixins: [uidMixin, carbonPrefixMixin],
props: {
alignment: { type: String, default: 'center', validator: val => ['start', 'center', 'end'].includes(val) },
alignment: { type: String, default: 'center', validator: val => alignments.includes(val) },
definition: { type: String, required: true },
direction: {
type: String,
default: 'top',
validator(val) {
const validValues = ['top', 'left', 'right', 'bottom'];
const valid = validValues.includes(val);
validator: val => {
const valid = directions.includes(val);
if (!valid) {
console.warn(`CVDefinitionTooltip.direction must be one of the following: ${validValues}`);
console.warn(`CVDefinitionTooltip.direction must be one of the following: ${directions}`);
}
return valid;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
class="cv-interactive-tooltip__before-content"
ref="beforeContent"
tabindex="0"
style="position: absolute; left: -9999px; width: 1px; height: 1px;"
style="position: absolute; left: -9999px; width: 1px; height: 1px"
@focus="focusBeforeContent"
/>
<span :class="`${carbonPrefix}--tooltip__caret`"></span>
Expand All @@ -57,7 +57,7 @@
class="cv-interactive-tooltip__after-content"
ref="afterContent"
tabindex="0"
style="position: absolute; left: -9999px; width: 1px; height: 1px;"
style="position: absolute; left: -9999px; width: 1px; height: 1px"
@focus="focusAfterContent"
/>
</div>
Expand All @@ -67,21 +67,21 @@
<script>
import { uidMixin, carbonPrefixMixin } from '../../mixins';
import Information16 from '@carbon/icons-vue/es/information/16';
import { alignments, directions } from './consts';
export default {
name: 'CvInteractiveTooltip',
mixins: [uidMixin, carbonPrefixMixin],
components: { Information16 },
props: {
alignment: { type: String, default: 'center', validator: val => ['start', 'center', 'end'].includes(val) },
alignment: { type: String, default: 'center', validator: val => alignments.includes(val) },
direction: {
type: String,
default: 'top',
validator(val) {
const validValues = ['top', 'bottom', 'right', 'left'];
const valid = validValues.includes(val);
validator: val => {
const valid = directions.includes(val);
if (!valid) {
console.warn(`CVInteractiveTooltip.direction must be one of the following: ${validValues}`);
console.warn(`CVInteractiveTooltip.direction must be one of the following: ${directions}`);
}
return valid;
},
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/components/cv-tooltip/cv-tooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@
<script>
import Information16 from '@carbon/icons-vue/es/information/16';
import { carbonPrefixMixin } from '../../mixins';
import { alignments, directions } from './consts';
export default {
name: 'CvTooltip',
mixins: [carbonPrefixMixin],
components: { Information16 },
props: {
alignment: { type: String, default: 'center', validator: val => ['start', 'center', 'end'].includes(val) },
alignment: { type: String, default: 'center', validator: val => alignments.includes(val) },
direction: {
type: String,
default: 'top',
validator(val) {
const validValues = ['top', 'left', 'right', 'bottom'];
const valid = validValues.includes(val);
validator: val => {
const valid = directions.includes(val);
if (!valid) {
console.warn(`CVTooltip.direction must be one of the following: ${validValues}`);
console.warn(`CVTooltip.direction must be one of the following: ${directions}`);
}
return valid;
},
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/components/cv-tooltip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import CvTooltip from './cv-tooltip';
import CvInteractiveTooltip from './cv-interactive-tooltip';
import CvDefinitionTooltip from './cv-definition-tooltip';

export { alignments, directions } from './consts';
export { CvTooltip, CvInteractiveTooltip, CvDefinitionTooltip };

0 comments on commit 2ca0796

Please sign in to comment.