-
Notifications
You must be signed in to change notification settings - Fork 309
feat(qr-code): Add the necessary attributes to the responsive #3456
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
Conversation
WalkthroughThe changes introduce a button to dynamically change the QR code color in two Vue demo files and update the QR code rendering logic to react to additional property changes. The QR code component now responds to color and other property updates, enabling interactive customization in the demos. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Button ("改变颜色")
participant VueComponent
participant QRCode
User->>Button: Click "改变颜色"
Button->>VueComponent: Trigger changeColor()
VueComponent->>QRCode: Update color property
QRCode->>QRCode: React to color change, redraw QR code
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/renderless/src/qr-code/vue.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-vue". (The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
WalkthroughThis PR introduces responsive attributes to the QR code component, enhancing its functionality by adding a button to change the QR code color dynamically. The changes involve updates to the demo files and the core QR code rendering logic to support additional properties. Changes
|
}) | ||
|
||
const changeColor = () => { | ||
params.value.color = '#666' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line params.value.color = '#666'
seems to be incorrect. It should be params.value.color
instead of params.color
. Please verify the correct property path.
}, | ||
methods: { | ||
changeColor() { | ||
this.params.color = '#666' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line this.params.color = '#666'
seems to be incorrect. It should be this.params.color
instead of this.params.color
. Please verify the correct property path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
packages/renderless/src/qr-code/vue.ts (1)
23-39
:⚠️ Potential issueFix duplicate property in watch array.
The expanded watch dependencies correctly enable QR code responsiveness to additional properties, which aligns well with the PR objectives. However,
props.level
is included twice in the array (lines 25 and 31).Apply this diff to remove the duplicate:
watch( () => [ props.level, props.value, props.color, props.style, props.size, props.icon, - props.level, props.iconSize, props.bordered ], () => { api.draw() api.change() } )
🧹 Nitpick comments (2)
examples/sites/demos/pc/app/qr-code/style.vue (1)
29-33
: Consider making color changes more dynamic.The
changeColor
method correctly demonstrates the responsive behavior. For enhanced demo experience, consider cycling through multiple colors instead of a single hardcoded value.Optional enhancement to cycle through multiple colors:
+ data() { + return { + params: { /* existing params */ }, + colorIndex: 0, + colors: ['#1677ff', '#666', '#ff4d4f', '#52c41a', '#faad14'] + } + }, methods: { changeColor() { - this.params.color = '#666' + this.colorIndex = (this.colorIndex + 1) % this.colors.length + this.params.color = this.colors[this.colorIndex] } }examples/sites/demos/pc/app/qr-code/style-composition-api.vue (1)
15-24
: LGTM! Correct reactive reference implementation.The conversion of
params
to aref()
and accessing the color viaparams.value.color
in thechangeColor
function correctly implements Vue 3 composition API patterns.Similar to the options API version, consider making the color changes more dynamic:
+const colorIndex = ref(0) +const colors = ['#1677ff', '#666', '#ff4d4f', '#52c41a', '#faad14'] + const changeColor = () => { - params.value.color = '#666' + colorIndex.value = (colorIndex.value + 1) % colors.length + params.value.color = colors[colorIndex.value] }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
examples/sites/demos/pc/app/qr-code/style-composition-api.vue
(1 hunks)examples/sites/demos/pc/app/qr-code/style.vue
(2 hunks)packages/renderless/src/qr-code/vue.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (4)
examples/sites/demos/pc/app/qr-code/style.vue (2)
1-9
: LGTM! Clean template structure for interactive demo.The template changes effectively demonstrate the QR code responsiveness feature with a clear container structure and interactive button.
12-17
: LGTM! Proper component imports and registration.The TinyButton component is correctly imported and registered alongside TinyQrCode.
examples/sites/demos/pc/app/qr-code/style-composition-api.vue (2)
1-9
: LGTM! Consistent template structure across API styles.The template structure matches the options API version perfectly, providing consistent demo experience across different Vue API styles.
12-13
: LGTM! Proper imports for composition API.The imports correctly include TinyButton and ref from Vue for the composition API approach.
feat(qr-code): 将必要的属性,添加响应式
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
New Features
Bug Fixes