Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(numeric): [numeric]refactor numeric theme vars #2200

Merged
merged 1 commit into from
Sep 29, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<div class="f-r f-box-center">
<span>全部禁用:</span>
<tiny-numeric v-model="value1" :disabled="disabled" class="mr20"></tiny-numeric>
<tiny-numeric v-model="value1" :disabled="disabled" unit="kg" class="mr20"></tiny-numeric>
<tiny-numeric v-model="value1" :disabled="disabled" :controls="false" show-left class="mr20"></tiny-numeric>
<tiny-numeric v-model="value1" :disabled="disabled" controls-position="right" class="mr20"></tiny-numeric>
<span>部分禁用:</span>
<tiny-numeric v-model="value2" :min="min" :max="max"></tiny-numeric>
</div>
Expand All @@ -17,3 +20,9 @@ const disabled = ref(true)
const min = ref(0)
const max = ref(10)
</script>

<style scoped>
.mr20 {
margin-right: 20px;
}
</style>
9 changes: 9 additions & 0 deletions examples/sites/demos/pc/app/numeric/dynamic-disabled.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<div class="f-r f-box-center">
<span>全部禁用:</span>
<tiny-numeric v-model="value1" :disabled="disabled" class="mr20"></tiny-numeric>
<tiny-numeric v-model="value1" :disabled="disabled" unit="kg" class="mr20"></tiny-numeric>
<tiny-numeric v-model="value1" :disabled="disabled" :controls="false" show-left class="mr20"></tiny-numeric>
<tiny-numeric v-model="value1" :disabled="disabled" controls-position="right" class="mr20"></tiny-numeric>
Comment on lines +5 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Consider using separate v-model bindings for each component.

The additions effectively demonstrate various configurations of the <tiny-numeric> component, which is great for showcasing its versatility. However, using the same v-model="value1" for all components might lead to unexpected behavior, as changing one component will update all others.

Consider using separate v-model bindings for each component to ensure independent behavior. For example:

<tiny-numeric v-model="value1" :disabled="disabled" unit="kg" class="mr20"></tiny-numeric>
<tiny-numeric v-model="value2" :disabled="disabled" :controls="false" show-left class="mr20"></tiny-numeric>
<tiny-numeric v-model="value3" :disabled="disabled" controls-position="right" class="mr20"></tiny-numeric>

Then update the data() section accordingly:

data() {
  return {
    value1: 1,
    value2: 1,
    value3: 1,
    // ... other properties
  }
}

The consistent use of the "mr20" class and the variety of component configurations are good practices for maintaining uniform spacing and demonstrating component flexibility.

<span>部分禁用:</span>
<tiny-numeric v-model="value2" :min="min" :max="max"></tiny-numeric>
</div>
Expand All @@ -25,3 +28,9 @@ export default {
}
}
</script>

<style scoped>
.mr20 {
margin-right: 20px;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<div>
<tiny-numeric v-model="value" size="medium"></tiny-numeric>
<br /><br />
<tiny-numeric v-model="value"></tiny-numeric>
<br /><br />
<tiny-numeric v-model="value" size="small"></tiny-numeric>
<br /><br />
<tiny-numeric v-model="value" size="mini"></tiny-numeric>
<br /><br />
<tiny-numeric v-model="value"></tiny-numeric>
</div>
</template>

Expand Down
4 changes: 2 additions & 2 deletions examples/sites/demos/pc/app/numeric/numeric-size.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ test('尺寸', async ({ page }) => {
await largeNumeric.locator('.tiny-numeric__increase').click()

// small尺寸
const smallNumeric = page.locator('.tiny-numeric').nth(1)
const smallNumeric = page.locator('.tiny-numeric').nth(2)
await expect(smallNumeric).toHaveClass(/tiny-numeric--small/)
await smallNumeric.getByRole('spinbutton').fill('111')
await smallNumeric.locator('.tiny-numeric__decrease').click()
await smallNumeric.locator('.tiny-numeric__increase').click()

// mini尺寸
const miniNumeric = page.locator('.tiny-numeric').nth(2)
const miniNumeric = page.locator('.tiny-numeric').nth(3)
await expect(miniNumeric).toHaveClass(/tiny-numeric--mini/)
await miniNumeric.getByRole('spinbutton').fill('100')
await miniNumeric.locator('.tiny-numeric__decrease').click()
Expand Down
4 changes: 2 additions & 2 deletions examples/sites/demos/pc/app/numeric/numeric-size.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<div>
<tiny-numeric v-model="value" size="medium"></tiny-numeric>
<br /><br />
<tiny-numeric v-model="value"></tiny-numeric>
<br /><br />
<tiny-numeric v-model="value" size="small"></tiny-numeric>
<br /><br />
<tiny-numeric v-model="value" size="mini"></tiny-numeric>
<br /><br />
<tiny-numeric v-model="value"></tiny-numeric>
</div>
</template>

Expand Down
Loading
Loading