Skip to content

Commit

Permalink
Review Changes Abbr, Accordion, Avatar
Browse files Browse the repository at this point in the history
Refs: #7036
  • Loading branch information
AlexanderSchmidtCE committed Nov 14, 2024
1 parent 3dba735 commit ce9899c
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 49 deletions.
4 changes: 2 additions & 2 deletions packages/components/src/components/abbr/shadow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export class KolAbbr implements AbbrAPI {

public render(): JSX.Element {
return (
<Host class="kol-abbr">
<Host>
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}
<abbr class="kol-abbr__abbr" aria-labelledby={this.nonce} role="definition" tabindex="0" title={this.state._label}>
<abbr aria-labelledby={this.nonce} class="kol-abbr" role="definition" tabindex="0" title={this.state._label}>
<span title="">
<slot />
</span>
Expand Down
8 changes: 2 additions & 6 deletions packages/components/src/components/abbr/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
@import '../style';

@layer kol-component {
:host {
font-size: rem(16);
}
.kol-abbr {
&__abbr {
cursor: help;
}
font-size: rem(16);
cursor: help;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`kol-abbr should render with _label="Text" _tooltipAlign="bottom" 1`] = `
<kol-abbr class="kol-abbr">
<kol-abbr>
<template shadowrootmode="open">
<abbr aria-labelledby="nonce" class="kol-abbr__abbr" role="definition" tabindex="0" title="Text">
<abbr aria-labelledby="nonce" class="kol-abbr" role="definition" tabindex="0" title="Text">
<span>
<slot></slot>
</span>
Expand All @@ -14,9 +14,9 @@ exports[`kol-abbr should render with _label="Text" _tooltipAlign="bottom" 1`] =
`;

exports[`kol-abbr should render with _label="Text" _tooltipAlign="left" 1`] = `
<kol-abbr class="kol-abbr">
<kol-abbr>
<template shadowrootmode="open">
<abbr aria-labelledby="nonce" class="kol-abbr__abbr" role="definition" tabindex="0" title="Text">
<abbr aria-labelledby="nonce" class="kol-abbr" role="definition" tabindex="0" title="Text">
<span>
<slot></slot>
</span>
Expand All @@ -27,9 +27,9 @@ exports[`kol-abbr should render with _label="Text" _tooltipAlign="left" 1`] = `
`;

exports[`kol-abbr should render with _label="Text" _tooltipAlign="right" 1`] = `
<kol-abbr class="kol-abbr">
<kol-abbr>
<template shadowrootmode="open">
<abbr aria-labelledby="nonce" class="kol-abbr__abbr" role="definition" tabindex="0" title="Text">
<abbr aria-labelledby="nonce" class="kol-abbr" role="definition" tabindex="0" title="Text">
<span>
<slot></slot>
</span>
Expand All @@ -40,9 +40,9 @@ exports[`kol-abbr should render with _label="Text" _tooltipAlign="right" 1`] = `
`;

exports[`kol-abbr should render with _label="Text" _tooltipAlign="top" 1`] = `
<kol-abbr class="kol-abbr">
<kol-abbr>
<template shadowrootmode="open">
<abbr aria-labelledby="nonce" class="kol-abbr__abbr" role="definition" tabindex="0" title="Text">
<abbr aria-labelledby="nonce" class="kol-abbr" role="definition" tabindex="0" title="Text">
<span>
<slot></slot>
</span>
Expand All @@ -53,9 +53,9 @@ exports[`kol-abbr should render with _label="Text" _tooltipAlign="top" 1`] = `
`;

exports[`kol-abbr should render with _label="Text" 1`] = `
<kol-abbr class="kol-abbr">
<kol-abbr>
<template shadowrootmode="open">
<abbr aria-labelledby="nonce" class="kol-abbr__abbr" role="definition" tabindex="0" title="Text">
<abbr aria-labelledby="nonce" class="kol-abbr" role="definition" tabindex="0" title="Text">
<span>
<slot></slot>
</span>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/accordion/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@import '../../functional-components/Collapsible/collapsible';

@layer kol-component {
:host {
.kol-accordion {
font-size: rem(16);
}
}
22 changes: 10 additions & 12 deletions packages/components/src/components/avatar/component.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { JSX } from '@stencil/core';
import { validateImageSource, validateLabel } from '../../schema';
import { Component, h, Host, Prop, State, Watch } from '@stencil/core';
import { Component, h, Prop, State, Watch } from '@stencil/core';

import { translate } from '../../i18n';
import { formatLabelAsInitials } from './controller';
Expand All @@ -17,17 +17,15 @@ import type { AvatarAPI, AvatarStates, ImageSourcePropType, LabelPropType } from
export class KolAvatarWc implements AvatarAPI {
public render(): JSX.Element {
return (
<Host class="kol-avatar">
<div aria-label={translate('kol-avatar-alt', { placeholders: { name: this.state._label } })} class="kol-avatar__container" role="img">
{this.state._src ? (
<img alt="" aria-hidden="true" class="kol-avatar__image" src={this.state._src} />
) : (
<span aria-hidden="true" class="kol-avatar__initials">
{formatLabelAsInitials(this.state._label.trim())}
</span>
)}
</div>
</Host>
<div aria-label={translate('kol-avatar-alt', { placeholders: { name: this.state._label } })} class="kol-avatar" role="img">
{this.state._src ? (
<img alt="" aria-hidden="true" class="kol-avatar__image" src={this.state._src} />
) : (
<span aria-hidden="true" class="kol-avatar__initials">
{formatLabelAsInitials(this.state._label.trim())}
</span>
)}
</div>
);
}

Expand Down
20 changes: 8 additions & 12 deletions packages/components/src/components/avatar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@
@import '../host-display-block';

@layer kol-component {
:host {
font-size: rem(16);
}
.kol-avatar {
&__container {
border-radius: 50%;
overflow: hidden;
/* Visible with forced colors */
outline: transparent solid rem(1);
/*theme?*/
width: rem(100);
height: rem(100);
}
font-size: rem(16);
border-radius: 50%;
overflow: hidden;
/* Visible with forced colors */
outline: transparent solid rem(1);
/*theme?*/
width: rem(100);
height: rem(100);

&__image {
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
exports[`kol-avatar should render with _label="Erika Maria Mustermann" _src=undefined 1`] = `
<kol-avatar>
<template shadowrootmode="open">
<kol-avatar-wc class="kol-avatar">
<div aria-label="kol-avatar-alt" class="kol-avatar__container" role="img">
<kol-avatar-wc>
<div aria-label="kol-avatar-alt" class="kol-avatar" role="img">
<span aria-hidden="true" class="kol-avatar__initials">
EM
</span>
Expand All @@ -17,8 +17,8 @@ exports[`kol-avatar should render with _label="Erika Maria Mustermann" _src=unde
exports[`kol-avatar should render with _label="Erika" _src="/image.webp" 1`] = `
<kol-avatar>
<template shadowrootmode="open">
<kol-avatar-wc class="kol-avatar">
<div aria-label="kol-avatar-alt" class="kol-avatar__container" role="img">
<kol-avatar-wc>
<div aria-label="kol-avatar-alt" class="kol-avatar" role="img">
<img alt="" aria-hidden="true" class="kol-avatar__image" src="/image.webp">
</div>
</kol-avatar-wc>
Expand All @@ -29,8 +29,8 @@ exports[`kol-avatar should render with _label="Erika" _src="/image.webp" 1`] = `
exports[`kol-avatar should render with _label="Erika" _src=undefined 1`] = `
<kol-avatar>
<template shadowrootmode="open">
<kol-avatar-wc class="kol-avatar">
<div aria-label="kol-avatar-alt" class="kol-avatar__container" role="img">
<kol-avatar-wc>
<div aria-label="kol-avatar-alt" class="kol-avatar" role="img">
<span aria-hidden="true" class="kol-avatar__initials">
E
</span>
Expand Down

0 comments on commit ce9899c

Please sign in to comment.