Skip to content

Commit

Permalink
[pre-commit.ci lite] apply automatic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci-lite[bot] authored Feb 21, 2025
1 parent c92f603 commit d72366c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 39 deletions.
14 changes: 6 additions & 8 deletions packages/kolibri-common/components/MetadataChips.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<template>

<div
class="metadata-chips"
>
<div class="metadata-chips">
<div
v-for="({ label, key, icon }) in tags"
v-for="{ label, key, icon } in tags"
:key="key"
:style="{ backgroundColor: $themePalette.grey.v_100 }"
class="chip"
>
<KIcon
v-if="icon"
class='icon'
class="icon"
:icon="icon"
/>
<span
Expand Down Expand Up @@ -43,7 +41,7 @@
tags: {
type: Array,
required: true,
validator: (tags) => tags.every(tag => tag.label && tag.key),
validator: tags => tags.every(tag => tag.label && tag.key),
},
},
};
Expand All @@ -66,12 +64,12 @@
}
.icon {
top: 0!important;
top: 0 !important;
}
.chip {
display: flex;
position: relative;
display: flex;
padding: 4px;
margin-right: 4px;
}
Expand Down
56 changes: 25 additions & 31 deletions packages/kolibri-common/composables/useCoachMetadataTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import useLearningActivities from 'kolibri-common/composables/useLearningActivit
import { ActivitiesLookup, ContentNodeKinds, LearningActivities } from 'kolibri/constants';
import { coreString, coreStrings } from 'kolibri/uiText/commonCoreStrings';


/**
* Create a tag Object
* @param {string} label - text to display
* @param {string} key - unique key for the tag - should map to le-utils constants
* @param {string} icon - icon to display (mapping to KIcon)
*/
* Create a tag Object
* @param {string} label - text to display
* @param {string} key - unique key for the tag - should map to le-utils constants
* @param {string} icon - icon to display (mapping to KIcon)
*/
function createTag(label, key, icon) {
return {
label,
Expand All @@ -19,16 +18,15 @@ function createTag(label, key, icon) {
}

export function useCoachMetadataTags(contentNode) {

const { durationEstimation } = useLearningActivities(contentNode);

const tags = ref([]);

function getKindTag() {
if(contentNode.kind === ContentNodeKinds.CHANNEL) {
if (contentNode.kind === ContentNodeKinds.CHANNEL) {
return createTag(coreStrings.$tr('channel'), 'channel');
}
if(contentNode.kind === ContentNodeKinds.TOPIC) {
if (contentNode.kind === ContentNodeKinds.TOPIC) {
return createTag(coreStrings.$tr('folder'), 'folder', 'topic');
}
}
Expand All @@ -40,8 +38,8 @@ export function useCoachMetadataTags(contentNode) {

const getLevelTags = () => {
if (!contentNode.grade_levels) return [];
return contentNode.grade_levels.map(
grade_levels => createTag(coreString(grade_levels), grade_levels)
return contentNode.grade_levels.map(grade_levels =>
createTag(coreString(grade_levels), grade_levels),
);
};

Expand All @@ -53,20 +51,22 @@ export function useCoachMetadataTags(contentNode) {
const getActivityTags = () => {
if (!contentNode.learning_activities) return [];

if(contentNode.learning_activities.length > 1) {
return createTag(coreStrings.$tr('multipleLearningActivities'), 'multipleLearningActivities', 'allActivities');
if (contentNode.learning_activities.length > 1) {
return createTag(
coreStrings.$tr('multipleLearningActivities'),
'multipleLearningActivities',
'allActivities',
);
} else {
return contentNode.learning_activities.map(
activity => {
let icon;
if(activity === LearningActivities.EXPLORE) {
icon = "interactSolid";
} else {
icon = ActivitiesLookup[activity].toLowerCase() + "Solid";
}
return createTag(coreString(activity), activity, icon)
return contentNode.learning_activities.map(activity => {
let icon;
if (activity === LearningActivities.EXPLORE) {
icon = 'interactSolid';
} else {
icon = ActivitiesLookup[activity].toLowerCase() + 'Solid';
}
);
return createTag(coreString(activity), activity, icon);
});
}
};

Expand All @@ -92,20 +92,14 @@ export function useCoachMetadataTags(contentNode) {
};

const getFolderTags = () => {
return [
getKindTag(),
];
return [getKindTag()];
};

const getResourceTags = () => {
console.log(getActivityTags());
console.log(getDurationTag());
console.log(getCategoryTags());
return [
...getActivityTags(),
...getDurationTag(),
...getCategoryTags()
];
return [...getActivityTags(), ...getDurationTag(), ...getCategoryTags()];
};

if (
Expand Down

0 comments on commit d72366c

Please sign in to comment.