Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 9x 6x 9x 9x 9x 1x 1x 1x 1x 1x 1x 9x 9x 1x 1x | <template> <div class="cdx-info-chip"> <cdx-icon v-if="computedIcon" class="cdx-info-chip__icon" :class="iconClass" :icon="computedIcon" /> <span class="cdx-info-chip--text"> <!-- @slot Chip content. --> <slot /> </span> </div> </template> <script lang="ts"> import { defineComponent, PropType, computed } from 'vue'; import { statusTypeValidator } from '../../constants'; import { StatusType, StatusIconMap } from '../../types'; import { cdxIconError, cdxIconAlert, cdxIconSuccess, Icon } from '@wikimedia/codex-icons'; import CdxIcon from '../icon/Icon.vue'; const iconMap: Partial<StatusIconMap> = { error: cdxIconError, warning: cdxIconAlert, success: cdxIconSuccess }; /** * A non-interactive item that provides information. */ export default defineComponent( { name: 'CdxInfoChip', components: { CdxIcon }, props: { /** * Status type. * * @values 'notice', 'warning', 'error', 'success' */ status: { type: String as PropType<StatusType>, default: 'notice', validator: statusTypeValidator }, /** * Custom icon to use for "notice" chips. Chips with other status types * (warning, etc) do not allow custom icons and will ignore this option. */ icon: { type: [ String, Object ] as PropType<Icon>, default: null } }, setup( props ) { const iconClass = computed( (): Record<string, boolean> => { return { [ `cdx-info-chip__icon--${ props.status }` ]: true }; } ); // For notice messages, use a custom icon if provided. Otherwise, use the default icon. const computedIcon = computed( () => props.status === 'notice' ? props.icon : iconMap[ props.status ] ); return { iconClass, computedIcon }; } } ); </script> <style lang="less"> @import ( reference ) '@wikimedia/codex-design-tokens/theme-wikimedia-ui.less'; @import ( reference ) '../../themes/mixins/common.less'; .cdx-info-chip { background-color: @background-color-transparent; display: inline-flex; align-items: center; justify-content: center; gap: @spacing-25; max-width: @size-3200; border: @border-width-base @border-style-base @border-color-subtle; border-radius: @border-radius-pill; padding: 0 @spacing-50; line-height: @line-height-small; &--text { .text-overflow( @param-visible: false ); color: @color-subtle; font-size: @font-size-small; } &__icon { &--notice.cdx-icon { color: @color-notice; } &--error.cdx-icon { color: @color-error; } &--warning.cdx-icon { color: @color-warning; } &--success.cdx-icon { color: @color-success; } } .cdx-icon { min-width: @min-size-icon-small; min-height: @min-size-icon-small; width: @size-icon-small; height: @size-icon-small; } } </style> |