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

[CHUX-461] ec navigation link light mode #1949

Merged
merged 3 commits into from
May 9, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,38 @@ exports[`EcNavigationLink > as regular anchor > should be expanded by default 1`
</a>
`;

exports[`EcNavigationLink > as regular anchor > should be use light styles when isInLightMode is passed into 1`] = `
<a
class="ec-navigation-link ec-navigation-link--light-mode"
data-test="ec-navigation-link"
href="#/balances"
>
<svg
class="ec-icon ec-navigation-link__icon"
data-test="ec-navigation-link__icon"
height="24"
width="24"
>
<use
xlink:href="#ec-simple-check"
/>
</svg>
<transition-stub
appear="false"
css="true"
name="ec-navigation-link__text-fade"
persisted="true"
>
<span
class="ec-navigation-link__text"
data-test="ec-navigation-link__text"
>
Link
</span>
</transition-stub>
</a>
`;

exports[`EcNavigationLink > as regular anchor > should hide the text when is collapsed 1`] = `
<a
class="ec-navigation-link ec-navigation-link--is-collapsed"
Expand Down Expand Up @@ -331,6 +363,41 @@ exports[`EcNavigationLink > as router-link > should be expanded by default 1`] =
</ec-stub>
`;

exports[`EcNavigationLink > as router-link > should be use light styles when isInLightMode is passed into 1`] = `
<ec-stub
active-class="ec-navigation-link--is-active"
class="ec-navigation-link ec-navigation-link--light-mode"
data-test="ec-navigation-link ec-stub router-link-stub"
to="/balances"
>

<svg
class="ec-icon ec-navigation-link__icon"
data-test="ec-navigation-link__icon"
height="24"
width="24"
>
<use
xlink:href="#ec-simple-check"
/>
</svg>
<transition-stub
appear="false"
css="true"
name="ec-navigation-link__text-fade"
persisted="true"
>
<span
class="ec-navigation-link__text"
data-test="ec-navigation-link__text"
>
Link
</span>
</transition-stub>

</ec-stub>
`;

exports[`EcNavigationLink > as router-link > should hide the text when is collapsed 1`] = `
<ec-stub
active-class="ec-navigation-link--is-active"
Expand Down
12 changes: 12 additions & 0 deletions src/components/ec-navigation-link/ec-navigation-link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ describe('EcNavigationLink', () => {
expect(wrapper.findByDataTest('ec-navigation-link').classes('ec-navigation-link--is-compact')).toBe(true);
});

it('should be use light styles when isInLightMode is passed into', () => {
const wrapper = mountAsRouterLink({ isInLightMode: true });
expect(wrapper.element).toMatchSnapshot();
expect(wrapper.findByDataTest('ec-navigation-link').classes('ec-navigation-link--light-mode')).toBe(true);
});

it('should pass listeners from parent to the root', () => {
const clickSpy = vi.fn();
const wrapper = mountAsRouterLink({}, {
Expand Down Expand Up @@ -127,6 +133,12 @@ describe('EcNavigationLink', () => {
expect(wrapper.findByDataTest('ec-navigation-link').classes('ec-navigation-link--is-compact')).toBe(true);
});

it('should be use light styles when isInLightMode is passed into', () => {
const wrapper = mountAsAnchor({ isInLightMode: true });
expect(wrapper.element).toMatchSnapshot();
expect(wrapper.findByDataTest('ec-navigation-link').classes('ec-navigation-link--light-mode')).toBe(true);
});

it('should pass listeners from parent to the root', () => {
const clickSpy = vi.fn();
const wrapper = mountAsAnchor({}, {
Expand Down
18 changes: 18 additions & 0 deletions src/components/ec-navigation-link/ec-navigation-link.story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,21 @@ basic.args = {
basic.parameters = {
backgrounds: { default: DARK_THEME.name, values: [DARK_THEME] },
};

export const lightMode: StoryFn<typeof EcNavigationLink> = args => ({
components: { EcNavigationLink },
setup() {
return { args };
},
template: `
<ec-navigation-link v-bind="args" />
`,
});

lightMode.args = {
text: 'Trade Finance',
iconName: IconName.SIMPLE_TRADE_FINANCE,
iconSize: 30,
url: '/trade-finance',
isInLightMode: true,
};
10 changes: 10 additions & 0 deletions src/components/ec-navigation-link/ec-navigation-link.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'ec-navigation-link--is-active': isActive,
'ec-navigation-link--is-compact': isCompact,
'ec-navigation-link--is-collapsed': isCollapsed,
'ec-navigation-link--light-mode': isInLightMode,
}"
:to="url"
>
Expand Down Expand Up @@ -43,6 +44,7 @@
'ec-navigation-link--is-active': isActive,
'ec-navigation-link--is-compact': isCompact,
'ec-navigation-link--is-collapsed': isCollapsed,
'ec-navigation-link--light-mode': isInLightMode,
}"
:href="url"
:target="target"
Expand Down Expand Up @@ -108,6 +110,14 @@ withDefaults(defineProps<NavigationLinkProps>(), {
@apply tw-py-12 tw-px-28;
}

&--light-mode {
@apply tw-text-gray-3;

&:hover {
@apply tw-text-gray-2;
}
}

&__icon {
@apply tw-fill-current;
@apply tw-flex-shrink-0;
Expand Down
1 change: 1 addition & 0 deletions src/components/ec-navigation-link/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export interface NavigationLinkProps {
isCollapsed?: boolean,
isCompact?: boolean,
target?: string,
isInLightMode?: boolean,
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading