Skip to content

Commit

Permalink
[CHUX-661] Add prop to ec-letter-icon to control hover styles (#1980)
Browse files Browse the repository at this point in the history
* [CHUX-661] add missing exports

* [CHUX-661] add prop and styles

* [CHUX-661] add unit test

* 2.8.10

* [CHUX-661] rename prop
  • Loading branch information
raulwwq0 committed Jun 14, 2024
1 parent a8ee4cd commit 9b3f82e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ebury/chameleon-components",
"version": "2.8.9",
"version": "2.8.10",
"main": "src/main.ts",
"sideEffects": false,
"author": "Ebury Team (http://labs.ebury.rocks/)",
Expand Down
10 changes: 10 additions & 0 deletions src/components/ec-letter-icon/ec-letter-icon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,14 @@ describe('EcLetterIcon', () => {
expect(container.element.tagName).toContain('BUTTON');
expect(container.classes()).toContain('ec-letter-icon--clickable');
});

it('should add hover styles if "isParentHovered" prop is set', () => {
const wrapper = mountLetterIcon({
text: 'Test',
isParentHovered: true,
});

const container = wrapper.findByDataTest('ec-letter-icon');
expect(container.classes()).toContain('ec-letter-icon--hover-styles');
});
});
14 changes: 10 additions & 4 deletions src/components/ec-letter-icon/ec-letter-icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class="ec-letter-icon"
:class="{
'ec-letter-icon--clickable': isClickable,
'ec-letter-icon--hover-styles': isParentHovered,
[`ec-letter-icon--${size}`]: true,
}"
>
Expand All @@ -26,6 +27,7 @@ import { type LetterIconProps, LetterIconSize } from './types';
const props = withDefaults(defineProps<LetterIconProps>(), {
size: LetterIconSize.SMALL,
isClickable: false,
isParentHovered: false,
});
const firstLetter = computed(() => (props.text[0]?.toUpperCase()));
Expand Down Expand Up @@ -55,11 +57,15 @@ const firstLetter = computed(() => (props.text[0]?.toUpperCase()));
@apply tw-cursor-pointer tw-border-0 tw-p-0;
&:hover {
@apply tw-bg-gray-2;
@apply ec-letter-icon--hover-styles;
}
}
&--hover-styles {
@apply tw-bg-gray-2;
.ec-letter-icon__text {
@apply tw-text-gray-7;
}
.ec-letter-icon__text {
@apply tw-text-gray-7;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/components/ec-letter-icon/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface LetterIconProps {
text: string,
size?: LetterIconSize,
isClickable?: boolean,
isParentHovered?: boolean,
}

export enum LetterIconSize {
Expand Down

0 comments on commit 9b3f82e

Please sign in to comment.