Skip to content

Commit

Permalink
release(setting): v0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Jun 29, 2023
1 parent 6a17f3b commit 1314289
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
},
"setting": {
"install": true,
"version": "0.7.0",
"version": "0.8.0",
"style": true,
"icon": false,
"test": true,
Expand Down
47 changes: 47 additions & 0 deletions src/setting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@ class SettingItem {
detach() {
this.$container.remove()
}
disable() {
this.$container.addClass(this.setting.c('disabled'))
}
enable() {
this.$container.rmClass(this.setting.c('disabled'))
}
text() {
return this.$container.text()
}
Expand Down Expand Up @@ -354,6 +360,7 @@ class SettingSeparator extends SettingItem {
}

class SettingText extends SettingItem {
private $input: $.$
constructor(
setting: Setting,
key: string,
Expand All @@ -374,6 +381,15 @@ class SettingText extends SettingItem {
$input.val(value)

$input.on('change', () => this.onChange($input.val()))
this.$input = $input
}
disable() {
super.disable()
this.$input.attr('disabled', '')
}
enable() {
super.enable()
this.$input.rmAttr('disabled')
}
}

Expand All @@ -390,6 +406,7 @@ export interface INumberOptions {
}

class SettingNumber extends SettingItem {
private $input: $.$
constructor(
setting: Setting,
key: string,
Expand Down Expand Up @@ -452,6 +469,16 @@ class SettingNumber extends SettingItem {
$trackProgress.css('width', progress(val, min, max) + '%')
$value.text(toStr(val))
})

this.$input = $input
}
disable() {
super.disable()
this.$input.attr('disabled', '')
}
enable() {
super.enable()
this.$input.rmAttr('disabled')
}
}

Expand All @@ -460,6 +487,7 @@ const progress = (val: number, min: number, max: number) => {
}

class SettingCheckbox extends SettingItem {
private $input: $.$
constructor(
setting: Setting,
key: string,
Expand All @@ -485,10 +513,20 @@ class SettingCheckbox extends SettingItem {
input.checked = value

$input.on('change', () => this.onChange(input.checked))
this.$input = $input
}
disable() {
super.disable()
this.$input.attr('disabled', '')
}
enable() {
super.enable()
this.$input.rmAttr('disabled')
}
}

class SettingSelect extends SettingItem {
private $select: $.$
constructor(
setting: Setting,
key: string,
Expand Down Expand Up @@ -520,6 +558,15 @@ class SettingSelect extends SettingItem {

const $select = this.$container.find('select')
$select.on('change', () => this.onChange($select.val()))
this.$select = $select
}
disable() {
super.disable()
this.$select.attr('disabled', '')
}
enable() {
super.enable()
this.$select.rmAttr('disabled')
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/setting/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "setting",
"version": "0.7.0",
"version": "0.8.0",
"description": "Settings panel",
"dependencies": {
"micromark": "^3.1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/setting/story.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const def = story(

setting.appendTitle('Element')

setting.appendInput(
setting.appendText(
'searchKeyword',
'div',
'Search Keyword',
Expand Down
24 changes: 24 additions & 0 deletions src/setting/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,27 @@
}

.item-input {
&.disabled {
input {
opacity: 0.6;
}
}
input {
@include input();
width: 100%;
}
}

.item-number {
&.disabled {
input,
.range-container {
opacity: 0.6;
}
.range-container input {
opacity: 1;
}
}
input[type='number'] {
@include input();
width: 200px;
Expand Down Expand Up @@ -139,6 +153,11 @@
}

.item-checkbox {
&.disabled {
.control {
opacity: 0.6;
}
}
input {
@include checkbox();
align-self: flex-start;
Expand All @@ -153,6 +172,11 @@
}

.item-select {
&.disabled {
.select {
opacity: 0.6;
}
}
.select {
@include select();
select {
Expand Down
2 changes: 1 addition & 1 deletion src/toolbar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

.disabled {
pointer-events: none;
opacity: 0.8;
opacity: 0.6;
}

.theme-dark {
Expand Down

0 comments on commit 1314289

Please sign in to comment.