Skip to content

Commit

Permalink
Merge release-v4 into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVelezLl committed Sep 3, 2024
2 parents 6068f8e + c7432ff commit 18bbbca
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 29 deletions.
1 change: 0 additions & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
else
echo "containsChangelog=false" >> $GITHUB_OUTPUT
fi
- name: Results
run: |
if [[ "${{ steps.check_description.outputs.containsChangelog }}" == "true" || "${{ github.event.pull_request.user.login }}" == "dependabot[bot]" ]]; then
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,29 @@ Changelog is rather internal in nature. See release notes for the public overvie

## Version 4.x.x (`release-v4` branch)

<!-- [DO NOT REMOVE-USED BY GH ACTION] PASTE CHANGELOG -->

- [#767]
- **Description:** Bump KDS version to 4.5.0.
- **Products impact:** -.
- **Addresses:** -.
- **Components:** -.
- **Breaking:** -.
- **Impacts a11y:** -.
- **Guidance:** -.

[#767]: https://github.com/learningequality/kolibri-design-system/pull/767

- [#744]
- **Description:** Removes internal state management for checked & indeterminate in KCheckbox.
- **Products impact:** Updated API
- **Addresses:** https://github.com/learningequality/studio/issues/4636
- **Components:** KCheckbox
- **Breaking:** No
- **Impacts a11y:** No
- **Guidance:** If you use KCheckbox, it is your responsibility to handle the `change` event and update whether or not the given `checked` and `indeterminate` props reflect the reality that you expect.

[#744]: https://github.com/learningequality/kolibri-design-system/pull/744

- [#737]
- **Description:** Bump KDS version to 4.4.1.
Expand Down
40 changes: 34 additions & 6 deletions docs/pages/kcheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
<DocsShow>
<KCheckbox
label="Some label"
:checked="true"
:checked="checked1"
@change="checked1 = !checked1"
/>
<KCheckbox
label="Another label"
:checked="false"
:checked="checked2"
@change="checked2 = !checked2"
/>
</DocsShow>
</DocsPageSection>
Expand Down Expand Up @@ -39,7 +41,9 @@
<DocsShow>
<KCheckbox
label="Topic is selected"
:indeterminate="true"
:indeterminate="indeterminate3"
:checked="checked3"
@change="handle3"
/>
</DocsShow>
<p>
Expand All @@ -53,11 +57,11 @@
<!-- eslint-disable -->
<!-- prevent prettier from changing indentation -->
<DocsShowCode language="html">
<KCheckbox label="First lesson" />;
<KCheckbox label="First lesson" />
</DocsShowCode>
<!-- eslint-enable -->
<DocsShow>
<KCheckbox label="First lesson" />
<KCheckbox label="First lesson" :checked="checked4" @change="checked4 = !checked4" />
</DocsShow>

In more complex situations, for example when another component is responsible for rendering the label, the default slot can be used:
Expand All @@ -71,7 +75,7 @@
</DocsShowCode>
<!-- eslint-enable -->
<DocsShow>
<KCheckbox>
<KCheckbox :checked="checked5" @change="checked5 = !checked5">
<KLabeledIcon icon="lesson" label="First lesson" />
</KCheckbox>
</DocsShow>
Expand All @@ -97,3 +101,27 @@
</DocsPageTemplate>

</template>


<script>
export default {
data() {
return {
checked1: true,
checked2: false,
checked3: false,
indeterminate3: true,
checked4: false,
checked5: false,
};
},
methods: {
handle3() {
this.checked3 = !this.checked3;
this.indeterminate3 = false;
},
},
};
</script>
28 changes: 6 additions & 22 deletions lib/KCheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
type="checkbox"
class="k-checkbox-input"
:aria-checked="ariaChecked"
:checked="isCurrentlyChecked"
:indeterminate.prop="isCurrentlyIndeterminate"
:checked="checked"
:indeterminate.prop="indeterminate"
:disabled="disabled"
@click.stop="toggleCheck"
@focus="isActive = true"
Expand All @@ -24,13 +24,13 @@
>

<KIcon
v-if="isCurrentlyIndeterminate"
v-if="indeterminate"
:style="notBlank"
class="checkbox-icon"
icon="indeterminateCheck"
/>
<KIcon
v-else-if="!isCurrentlyIndeterminate && isCurrentlyChecked"
v-else-if="!indeterminate && checked"
:style="[ notBlank, activeOutline ]"
class="checkbox-icon"
icon="checked"
Expand Down Expand Up @@ -122,13 +122,11 @@
},
},
data: () => ({
isCurrentlyChecked: false,
isCurrentlyIndeterminate: false,
isActive: false,
}),
computed: {
ariaChecked() {
return this.isCurrentlyIndeterminate ? 'mixed' : this.isCurrentlyChecked ? 'true' : 'false';
return this.indeterminate ? 'mixed' : this.checked ? 'true' : 'false';
},
id() {
return `k-checkbox-${this._uid}`;
Expand All @@ -152,28 +150,14 @@
};
},
},
watch: {
checked(newCheckedState) {
this.isCurrentlyChecked = newCheckedState;
},
indeterminate(newIndeterminateState) {
this.isCurrentlyIndeterminate = newIndeterminateState;
},
},
created() {
this.isCurrentlyChecked = this.checked;
this.isCurrentlyIndeterminate = this.indeterminate;
},
methods: {
toggleCheck(event) {
if (!this.disabled) {
this.isCurrentlyChecked = !this.isCurrentlyChecked;
this.$refs.kCheckboxInput.focus();
this.isCurrentlyIndeterminate = false;
/**
* Emits change event
*/
this.$emit('change', this.isCurrentlyChecked, event);
this.$emit('change', !this.checked, event);
}
},
markInactive() {
Expand Down

0 comments on commit 18bbbca

Please sign in to comment.