Closed
Conversation
mhewson
reviewed
Apr 24, 2025
| const props = withDefaults(defineProps<surface>(), { | ||
| const props = withDefaults(defineProps<surface & { | ||
| /** URL for the background image */ | ||
| backgroundImage?: string; |
Member
There was a problem hiding this comment.
can this support multiple images? I assume we will see cases where the surface needs specific art direction and a team will need to manage the image and its properties for each breakpoint?
mhewson
approved these changes
Apr 24, 2025
| it('applies background image properties via style attribute', () => { | ||
| const wrapper = mount(CdrSurface, { | ||
| props: { | ||
| backgroundImage: 'path/to/image.jpg', |
Member
There was a problem hiding this comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add background image support
Overview
This PR enhances the
CdrSurfacecomponent by adding the capability to display background images. Users can now specify an image URL, along with optionalbackground-sizeandbackground-positionproperties.Key Changes
<CdrSurface>:backgroundImage(string): URL of the background image.backgroundSize(string, default: 'cover'): Sets thebackground-sizeCSS property.backgroundPosition(string, default: 'center'): Sets thebackground-positionCSS property.CdrSurface.vue):definePropsto include the new properties.imageStyles,rootProps) to dynamically generate inline styles that set CSS custom properties (--cdr-surface-background-image,--cdr-surface-background-size,--cdr-surface-background-position) whenbackgroundImageis provided.styles/CdrSurface.module.scss):background-image,background-size, andbackground-positionCSS rules that consume the corresponding CSS custom properties.background-repeat: no-repeatby default when a background image is applied.__tests__/CdrSurface.spec.js):examples/Surface.vue):backgroundImage,backgroundSize, andbackgroundPositionprops.Motivation
This feature provides developers with more flexibility in styling surface containers, allowing for richer visual designs by incorporating background imagery directly within the component's API.
How to Test
CdrSurfaceexamples page.npm run test) and ensure all tests pass.