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

fix: display of readonly rating on android #81

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
14 changes: 11 additions & 3 deletions angular/demo/src/app/samples/rating/readonly.route.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import {AgnosUIAngularModule} from '@agnos-ui/angular';
import {Component} from '@angular/core';
import {Component, inject} from '@angular/core';
import heartFill from '!raw-loader!bootstrap-icons/icons/heart-fill.svg';
import {DomSanitizer} from '@angular/platform-browser';

@Component({
standalone: true,
imports: [AgnosUIAngularModule],
template: `
<ng-template auRatingStar #custom let-fill="fill">
<span class="star" [class.full]="fill === 100"> <span class="half" [style.width.%]="fill">&hearts;</span>&hearts;</span>
<span class="star" [class.full]="fill === 100">
<span class="half" [style.width.%]="fill" [innerHTML]="sanitizer.bypassSecurityTrustHtml(heartFill)"></span>
<span [innerHTML]="sanitizer.bypassSecurityTrustHtml(heartFill)"></span>
</span>
</ng-template>
<au-rating class="rating-custom" [rating]="3.64" [slotStar]="custom" [readonly]="true" [maxRating]="5" ariaLabel="readonly rating" />
`,
})
export default class ReadonlyRatingComponent {}
export default class ReadonlyRatingComponent {
readonly sanitizer = inject(DomSanitizer);
readonly heartFill = heartFill;
}
7 changes: 6 additions & 1 deletion common/demo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ main {
.star {
position: relative;
display: inline-block;
font-size: 300%;
font-size: 2.5rem;
color: #d3d3d3;
svg {
width: 1em;
height: 1em;
padding-right: 0.1rem;
}
}

.full {
Expand Down
2 changes: 1 addition & 1 deletion e2e/rating/rating.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
text: '3.64 out of 5',
disabled: null,
readonly: 'true',
stars: ['♥♥', '♥♥', '♥♥', '♥♥', '♥♥'],
stars: ['', '', '', '', ''],
classes: expectedClasses,
};
expect(await ratingPO.state()).toEqual(expectedState);
Expand Down Expand Up @@ -197,7 +197,7 @@
text: '3 out of 20',
classes: createArray(20, ['au-rating-star']),
};
expect(await ratingPO.state()).toEqual(expectedState);

Check failure on line 200 in e2e/rating/rating.e2e-spec.ts

View workflow job for this annotation

GitHub Actions / e2e-tests / Test (7/10)

[react:webkit] › rating/rating.e2e-spec.ts:170:2 › Rating tests › Config

1) [react:webkit] › rating/rating.e2e-spec.ts:170:2 › Rating tests › Config ────────────────────── Error: expect(received).toEqual(expected) // deep equality - Expected - 42 + Received + 2 @@ -28,69 +28,29 @@ "au-rating-star", ], Array [ "au-rating-star", ], - Array [ - "au-rating-star", - ], - Array [ - "au-rating-star", - ], - Array [ - "au-rating-star", - ], - Array [ - "au-rating-star", - ], - Array [ - "au-rating-star", - ], - Array [ - "au-rating-star", - ], - Array [ - "au-rating-star", - ], - Array [ - "au-rating-star", ], - Array [ - "au-rating-star", - ], - Array [ - "au-rating-star", - ], - ], "disabled": "true", - "max": "20", + "max": "10", "min": "0", "readonly": null, "rootClasses": Array [ "d-inline-flex", "au-rating", ], "stars": Array [ "★", "★", "★", - "☆", "☆", "☆", "☆", "☆", "☆", "☆", "☆", - "☆", - "☆", - "☆", - "☆", - "☆", - "☆", - "☆", - "☆", - "☆", ], - "text": "3 out of 20", + "text": "3 out of 10", "value": "3", } 198 | classes: createArray(20, ['au-rating-star']), 199 | }; > 200 | expect(await ratingPO.state()).toEqual(expectedState); | ^ 201 | 202 | await ratingDemoPO.locatorBtnConfigSlotStar("'*'").click(); 203 | expectedState = { at /home/runner/work/AgnosUI/AgnosUI/e2e/rating/rating.e2e-spec.ts:200:34

await ratingDemoPO.locatorBtnConfigSlotStar("'*'").click();
expectedState = {
Expand Down
150 changes: 140 additions & 10 deletions e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-readonly.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,35 @@
class="half"
style="width: 100%;"
>
"♥"
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
<span>
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
"♥"
</span>
</span>
<span
Expand All @@ -53,9 +79,35 @@
class="half"
style="width: 100%;"
>
"♥"
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
<span>
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
"♥"
</span>
</span>
<span
Expand All @@ -74,9 +126,35 @@
class="half"
style="width: 100%;"
>
"♥"
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
<span>
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
"♥"
</span>
</span>
<span
Expand All @@ -95,9 +173,35 @@
class="half"
style="width: 64%;"
>
"♥"
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
<span>
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
"♥"
</span>
</span>
<span
Expand All @@ -116,9 +220,35 @@
class="half"
style="width: 0%;"
>
"♥"
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
<span>
<svg
class="bi bi-heart-fill"
fill="currentColor"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"
fill-rule="evenodd"
/>
</svg>
</span>
"♥"
</span>
</span>
</div>
Expand Down
7 changes: 3 additions & 4 deletions react/demo/app/samples/rating/Readonly.route.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {StarContext} from '@agnos-ui/core';
import {Rating} from '@agnos-ui/react';
import heartFill from 'bootstrap-icons/icons/heart-fill.svg?raw';

const RatingDemo = () => {
return (
Expand All @@ -19,10 +20,8 @@ const RatingDemo = () => {
};
return (
<span className={starClassname.join(' ')}>
<span className="half" style={styles}>
&hearts;
</span>
&hearts;
<span className="half" style={styles} dangerouslySetInnerHTML={{__html: heartFill}}></span>
<span dangerouslySetInnerHTML={{__html: heartFill}}></span>
</span>
);
}}
Expand Down
6 changes: 5 additions & 1 deletion svelte/demo/samples/rating/Readonly.route.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<script lang="ts">
import {Rating} from '@agnos-ui/svelte';
import heartFill from 'bootstrap-icons/icons/heart-fill.svg?raw';
</script>

<Rating className="rating-custom" rating={3.64} readonly={true} maxRating={5} ariaLabel="readonly rating">
<span slot="star" let:fill let:index class="star" class:full={fill === 100}>
<span class="half" style:width={fill + '%'}>&hearts;</span>&hearts;
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
<span class="half" style:width={fill + '%'}>{@html heartFill}</span>
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
<span>{@html heartFill}</span>
</span>
</Rating>
Loading