Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/rancher-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"node": ">=20.0.0"
},
"dependencies": {
"@rancher/icons": "^2.0.53",
"lodash.debounce": "4.0.8"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<script setup lang="ts">
import { RcStatusBadgeProps } from './types';
import { useStatusColors } from '@components/utils/status';

const props = defineProps<RcStatusBadgeProps>();

const { backgroundColor, borderColor, textColor } = useStatusColors(props, 'outlined');
</script>

<template>
Expand All @@ -27,47 +30,8 @@ const props = defineProps<RcStatusBadgeProps>();
font-size: 12px;
line-height: 19px;

&.info {
background-color: var(--rc-info-secondary);
border-color: var(--rc-info-secondary);
color: var(--rc-info);
}

&.success {
background-color: var(--rc-success-secondary);
border-color: var(--rc-success-secondary);
color: var(--rc-success);
}

&.warning {
background-color: var(--rc-warning);
border-color: var(--rc-warning);
color: var(--rc-warning-secondary);
}

&.error {
background-color: var(--rc-error);
border-color: var(--rc-error);
color: var(--rc-error-secondary);
}

&.unknown {
background-color: var(--rc-unknown);
border-color: var(--rc-unknown);
color: var(--rc-unknown-secondary);
}

&.none {
border-color: var(--rc-none);
color: var(--rc-none-secondary);
}

&.prime {
background-color: var(--rc-success-secondary);
border-color: var(--rc-success-secondary);
color: var(--rc-success);
font-size: 10px;
line-height: 15px;
}
background-color: v-bind(backgroundColor);
border-color: v-bind(borderColor);
color: v-bind(textColor);
}
</style>
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default } from './RcStatusBadge.vue';
export type { Status } from '../types';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Status } from '@components/Pill/types';
import { Status } from '@components/utils/status';

export interface RcStatusBadgeProps {
status: Status;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<script setup lang="ts">
import { RcStatusIndicatorProps } from './types';
import { useStatusColors } from '@components/utils/status';

const props = defineProps<RcStatusIndicatorProps>();

const { backgroundColor, borderColor } = useStatusColors(props, 'solid');
</script>

<template>
Expand Down Expand Up @@ -42,34 +45,8 @@ const props = defineProps<RcStatusIndicatorProps>();
border-radius: 2px;
}

&.info {
background-color: var(--rc-info);
border-color: var(--rc-info);
}

&.success {
background-color: var(--rc-success);
border-color: var(--rc-success);
}

&.warning {
background-color: var(--rc-warning);
border-color: var(--rc-warning);
}

&.error {
background-color: var(--rc-error);
border-color: var(--rc-error);
}

&.unknown {
background-color: var(--rc-unknown);
border-color: var(--rc-unknown);
}

&.none {
border-color: var(--rc-none);
}
background-color: v-bind(backgroundColor);
border-color: v-bind(borderColor);
}
}
</style>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Status } from '../types';
import { Status } from '@components/utils/status';

export type Shape = 'disc' | 'horizontal-bar' | 'vertical-bar';

export interface RcStatusIndicatorProps {
Expand Down
1 change: 0 additions & 1 deletion pkg/rancher-components/src/components/Pill/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export type Shape = 'disc' | 'horizontal-bar' | 'vertical-bar';
export type Status = 'info' | 'success' | 'warning' | 'error' | 'unknown' | 'none';
export type Type = 'active' | 'inactive';
51 changes: 51 additions & 0 deletions pkg/rancher-components/src/components/RcIcon/RcIcon.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { shallowMount } from '@vue/test-utils';
import RcIcon from './RcIcon.vue';

describe('rcIcon.vue', () => {
it('renders with the correct type class and size classes', () => {
const wrapper = shallowMount(RcIcon, {
props: {
size: 'medium',
type: 'search',
},
});

expect(wrapper.classes()).toContain('icon-search');
expect(wrapper.classes()).toContain('medium');
});

it('sets aria-hidden to true by default', () => {
const wrapper = shallowMount(RcIcon, {
props: {
size: 'medium',
type: 'search',
},
});

expect(wrapper.attributes('aria-hidden')).toBe('true');
});

it('sets aria-hidden to false when explicitly provided', () => {
const wrapper = shallowMount(RcIcon, {
props: {
size: 'medium',
type: 'search',
ariaHidden: false,
},
});

expect(wrapper.attributes('aria-hidden')).toBe('false');
});

it('sets aria-hidden to true when explicitly provided', () => {
const wrapper = shallowMount(RcIcon, {
props: {
size: 'medium',
type: 'search',
ariaHidden: true,
},
});

expect(wrapper.attributes('aria-hidden')).toBe('true');
});
});
46 changes: 46 additions & 0 deletions pkg/rancher-components/src/components/RcIcon/RcIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<script setup lang="ts">
import { RcIconProps, RcIconType, RcIconSize } from '@components/RcIcon/types';
import { computed } from 'vue';
import { useStatusColors } from '@components/utils/status';
const props = withDefaults(defineProps<RcIconProps>(), { size: 'small', ariaHidden: true });
const fontSize = computed(() => {
return RcIconSize[props.size];
});

const iconClass = computed(() => {
return RcIconType[props.type];
});

const status = computed(() => {
if (props.status && props.status !== 'inherit') {
return props.status;
}

return 'none';
});

const { textColor } = useStatusColors({ status: status.value }, 'outlined');

const color = computed(() => {
if (props.status === 'inherit') {
return 'inherit';
}

return textColor.value;
});
</script>

<template>
<i
class="rc-icon"
:class="{[props.size]: true, [iconClass]: true}"
:aria-hidden="props.ariaHidden"
/>
</template>

<style lang="scss" scoped>
.rc-icon {
font-size: v-bind(fontSize);
color: v-bind(color);
}
</style>
1 change: 1 addition & 0 deletions pkg/rancher-components/src/components/RcIcon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as RcIcon } from './RcIcon.vue';
160 changes: 160 additions & 0 deletions pkg/rancher-components/src/components/RcIcon/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
import { Status } from '../utils/status';

export const RcIconType = {
actions: 'icon-actions',
ai: 'icon-ai',
'alert-alt': 'icon-alert-alt',
alert: 'icon-alert',
anchor: 'icon-anchor',
apple: 'icon-apple',
application: 'icon-application',
apps: 'icon-apps',
archive: 'icon-archive',
'backup-restore': 'icon-backup-restore',
backup: 'icon-backup',
'brush-icon': 'icon-brush-icon',
'category-alt': 'icon-category-alt',
checkmark: 'icon-checkmark',
'chevron-beginning': 'icon-chevron-beginning',
'chevron-down': 'icon-chevron-down',
'chevron-end': 'icon-chevron-end',
'chevron-left': 'icon-chevron-left',
'chevron-right': 'icon-chevron-right',
'chevron-up': 'icon-chevron-up',
'circle-plus': 'icon-circle-plus',
cis: 'icon-cis',
close: 'icon-close',
'cluster-management': 'icon-cluster-management',
cluster: 'icon-cluster',
code: 'icon-code',
comment: 'icon-comment',
commit: 'icon-commit',
compass: 'icon-compass',
'confirmation-alt': 'icon-confirmation-alt',
copy: 'icon-copy',
dashboard: 'icon-dashboard',
dock: 'icon-dock',
docker: 'icon-docker',
document: 'icon-document',
'dot-half': 'icon-dot-half',
'dot-open': 'icon-dot-open',
dot: 'icon-dot',
'downgrade-alt': 'icon-downgrade-alt',
download: 'icon-download',
edit: 'icon-edit',
elemental: 'icon-elemental',
endpoints_connected: 'icon-endpoints_connected',
endpoints_disconnected: 'icon-endpoints_disconnected',
epinio: 'icon-epinio',
error: 'icon-error',
explore: 'icon-explore',
extension: 'icon-extension',
'external-link': 'icon-external-link',
file: 'icon-file',
filter_alt: 'icon-filter_alt',
flask: 'icon-flask',
fleet: 'icon-fleet',
folder: 'icon-folder',
fork: 'icon-fork',
gatekeeper: 'icon-gatekeeper',
gear: 'icon-gear',
gemini: 'icon-gemini',
git: 'icon-git',
github: 'icon-github',
gitlab: 'icon-gitlab',
globe: 'icon-globe',
groups: 'icon-groups',
harvester: 'icon-harvester',
helm: 'icon-helm',
hide: 'icon-hide',
history: 'icon-history',
home: 'icon-home',
'info-circle': 'icon-info-circle',
info: 'icon-info',
init_container: 'icon-init_container',
istio: 'icon-istio',
keyboard: 'icon-keyboard',
keyboard_tab: 'icon-keyboard_tab',
linux: 'icon-linux',
'list-flat': 'icon-list-flat',
'list-grouped': 'icon-list-grouped',
lock: 'icon-lock',
logging: 'icon-logging',
longhorn: 'icon-longhorn',
marketplace: 'icon-marketplace',
menu: 'icon-menu',
minus: 'icon-minus',
monitoring: 'icon-monitoring',
more: 'icon-more',
namespace: 'icon-namespace',
notifier: 'icon-notifier',
'notify-announcement': 'icon-notify-announcement',
'notify-bell': 'icon-notify-bell',
'notify-busy': 'icon-notify-busy',
'notify-error': 'icon-notify-error',
'notify-info': 'icon-notify-info',
'notify-tick': 'icon-notify-tick',
'notify-warning': 'icon-notify-warning',
ollama: 'icon-ollama',
openai: 'icon-openai',
'os-management': 'icon-os-management',
pause: 'icon-pause',
'pin-outlined': 'icon-pin-outlined',
pin: 'icon-pin',
pipeline: 'icon-pipeline',
play: 'icon-play',
plus: 'icon-plus',
pod_security: 'icon-pod_security',
print: 'icon-print',
'question-mark': 'icon-question-mark',
'quick-action': 'icon-quick-action',
'rancher-desktop': 'icon-rancher-desktop',
'rancher-observability': 'icon-rancher-observability',
'refresh-alt': 'icon-refresh-alt',
refresh: 'icon-refresh',
'repository-alt': 'icon-repository-alt',
repository: 'icon-repository',
rio: 'icon-rio',
'role-binding': 'icon-role-binding',
search: 'icon-search',
send: 'icon-send',
service: 'icon-service',
show: 'icon-show',
snapshot: 'icon-snapshot',
'sort-down': 'icon-sort-down',
'sort-up': 'icon-sort-up',
sort: 'icon-sort',
sources: 'icon-sources',
spinner: 'icon-spinner',
stackstate: 'icon-stackstate',
'star-open': 'icon-star-open',
star: 'icon-star',
storage: 'icon-storage',
'tag-alt': 'icon-tag-alt',
terminal: 'icon-terminal',
'thinking-process': 'icon-thinking-process',
trash: 'icon-trash',
unlock: 'icon-unlock',
'upgrade-alt': 'icon-upgrade-alt',
upload: 'icon-upload',
'user-check': 'icon-user-check',
'user-xmark': 'icon-user-xmark',
user: 'icon-user',
'version-alt': 'icon-version-alt',
warning: 'icon-warning',
windows: 'icon-windows',
};

export const RcIconSize = {
large: '25px',
medium: '18px',
small: '14px',
none: undefined
};

export interface RcIconProps {
size: keyof typeof RcIconSize;
type: keyof typeof RcIconType;
ariaHidden?: boolean;
status?: Status | 'inherit';
}
Loading