Skip to content

Commit

Permalink
feat(core/link-button): add link button component (#580)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Leroux <daniel.leroux@siemens.com>
  • Loading branch information
goncalosard and danielleroux committed Jun 29, 2023
1 parent 3b6dea9 commit d98cabc
Show file tree
Hide file tree
Showing 24 changed files with 595 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* SPDX-FileCopyrightText: 2023 Siemens AG
*
* SPDX-License-Identifier: MIT
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import { Component } from '@angular/core';

@Component({
selector: 'app-example',
template: `
<ix-link-button url="https://ix.siemens.io/" disabled
>Link text</ix-link-button
>
`,
})
export default class LinkButtonDisabled {}
18 changes: 18 additions & 0 deletions packages/angular-test-app/src/preview-examples/link-button.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* SPDX-FileCopyrightText: 2023 Siemens AG
*
* SPDX-License-Identifier: MIT
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import { Component } from '@angular/core';

@Component({
selector: 'app-example',
template: `
<ix-link-button url="https://ix.siemens.io/">Link text</ix-link-button>
`,
})
export default class LinkButton {}
22 changes: 22 additions & 0 deletions packages/angular/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,28 @@ export class IxKpi {
export declare interface IxKpi extends Components.IxKpi {}


@ProxyCmp({
inputs: ['disabled', 'target', 'url']
})
@Component({
selector: 'ix-link-button',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['disabled', 'target', 'url'],
})
export class IxLinkButton {
protected el: HTMLElement;
constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
c.detach();
this.el = r.nativeElement;
}
}


export declare interface IxLinkButton extends Components.IxLinkButton {}


@ProxyCmp({
inputs: ['applicationName', 'hideContextMenu', 'navigationTitle'],
methods: ['toggleSidebar', 'openOverlay', 'closeOverlay']
Expand Down
1 change: 1 addition & 0 deletions packages/angular/src/declare-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const DIRECTIVES = [
d.IxKeyValue,
d.IxKeyValueList,
d.IxKpi,
d.IxLinkButton,
d.IxMapNavigation,
d.IxMapNavigationOverlay,
d.IxMenu,
Expand Down
98 changes: 98 additions & 0 deletions packages/core/component-doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5649,6 +5649,104 @@
"parts": [],
"listeners": []
},
{
"dirPath": "./src/components/link-button",
"filePath": "./src/components/link-button/link-button.tsx",
"fileName": "link-button.tsx",
"readmePath": "./src/components/link-button/readme.md",
"usagesDir": "./src/components/link-button/usage",
"tag": "ix-link-button",
"overview": "",
"usage": {},
"docs": "",
"docsTags": [
{
"name": "since",
"text": "2.0.0"
}
],
"encapsulation": "shadow",
"dependents": [],
"dependencies": [
"ix-icon"
],
"dependencyGraph": {
"ix-link-button": [
"ix-icon"
]
},
"props": [
{
"name": "disabled",
"type": "boolean",
"mutable": false,
"attr": "disabled",
"reflectToAttr": false,
"docs": "Disable the link button",
"docsTags": [],
"default": "false",
"values": [
{
"type": "boolean"
}
],
"optional": false,
"required": false
},
{
"name": "target",
"type": "\"_blank\" | \"_parent\" | \"_self\" | \"_top\"",
"mutable": false,
"attr": "target",
"reflectToAttr": false,
"docs": "Specifies where to open the link\n\nhttps://www.w3schools.com/html/html_links.asp",
"docsTags": [],
"default": "'_self'",
"values": [
{
"value": "_blank",
"type": "string"
},
{
"value": "_parent",
"type": "string"
},
{
"value": "_self",
"type": "string"
},
{
"value": "_top",
"type": "string"
}
],
"optional": false,
"required": false
},
{
"name": "url",
"type": "string",
"mutable": false,
"attr": "url",
"reflectToAttr": false,
"docs": "Url for the link button",
"docsTags": [],
"values": [
{
"type": "string"
}
],
"optional": false,
"required": false
}
],
"methods": [],
"events": [],
"styles": [],
"slots": [],
"parts": [],
"listeners": []
},
{
"dirPath": "./src/components/map-navigation",
"filePath": "./src/components/map-navigation/map-navigation.tsx",
Expand Down
49 changes: 49 additions & 0 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,23 @@ export namespace Components {
"unit": string;
"value": string | number;
}
/**
* @since 2.0.0
*/
interface IxLinkButton {
/**
* Disable the link button
*/
"disabled": boolean;
/**
* Specifies where to open the link https://www.w3schools.com/html/html_links.asp
*/
"target": '_self' | '_blank' | '_parent' | '_top';
/**
* Url for the link button
*/
"url": string;
}
interface IxMapNavigation {
/**
* Application name
Expand Down Expand Up @@ -2462,6 +2479,15 @@ declare global {
prototype: HTMLIxKpiElement;
new (): HTMLIxKpiElement;
};
/**
* @since 2.0.0
*/
interface HTMLIxLinkButtonElement extends Components.IxLinkButton, HTMLStencilElement {
}
var HTMLIxLinkButtonElement: {
prototype: HTMLIxLinkButtonElement;
new (): HTMLIxLinkButtonElement;
};
interface HTMLIxMapNavigationElement extends Components.IxMapNavigation, HTMLStencilElement {
}
var HTMLIxMapNavigationElement: {
Expand Down Expand Up @@ -2763,6 +2789,7 @@ declare global {
"ix-key-value": HTMLIxKeyValueElement;
"ix-key-value-list": HTMLIxKeyValueListElement;
"ix-kpi": HTMLIxKpiElement;
"ix-link-button": HTMLIxLinkButtonElement;
"ix-map-navigation": HTMLIxMapNavigationElement;
"ix-map-navigation-overlay": HTMLIxMapNavigationOverlayElement;
"ix-menu": HTMLIxMenuElement;
Expand Down Expand Up @@ -3891,6 +3918,23 @@ declare namespace LocalJSX {
"unit"?: string;
"value"?: string | number;
}
/**
* @since 2.0.0
*/
interface IxLinkButton {
/**
* Disable the link button
*/
"disabled"?: boolean;
/**
* Specifies where to open the link https://www.w3schools.com/html/html_links.asp
*/
"target"?: '_self' | '_blank' | '_parent' | '_top';
/**
* Url for the link button
*/
"url"?: string;
}
interface IxMapNavigation {
/**
* Application name
Expand Down Expand Up @@ -4945,6 +4989,7 @@ declare namespace LocalJSX {
"ix-key-value": IxKeyValue;
"ix-key-value-list": IxKeyValueList;
"ix-kpi": IxKpi;
"ix-link-button": IxLinkButton;
"ix-map-navigation": IxMapNavigation;
"ix-map-navigation-overlay": IxMapNavigationOverlay;
"ix-menu": IxMenu;
Expand Down Expand Up @@ -5078,6 +5123,10 @@ declare module "@stencil/core" {
*/
"ix-key-value-list": LocalJSX.IxKeyValueList & JSXBase.HTMLAttributes<HTMLIxKeyValueListElement>;
"ix-kpi": LocalJSX.IxKpi & JSXBase.HTMLAttributes<HTMLIxKpiElement>;
/**
* @since 2.0.0
*/
"ix-link-button": LocalJSX.IxLinkButton & JSXBase.HTMLAttributes<HTMLIxLinkButtonElement>;
"ix-map-navigation": LocalJSX.IxMapNavigation & JSXBase.HTMLAttributes<HTMLIxMapNavigationElement>;
"ix-map-navigation-overlay": LocalJSX.IxMapNavigationOverlay & JSXBase.HTMLAttributes<HTMLIxMapNavigationOverlayElement>;
"ix-menu": LocalJSX.IxMenu & JSXBase.HTMLAttributes<HTMLIxMenuElement>;
Expand Down
73 changes: 73 additions & 0 deletions packages/core/src/components/link-button/link-button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* SPDX-FileCopyrightText: 2023 Siemens AG
*
* SPDX-License-Identifier: MIT
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

@import 'common-variables';
@import './components/buttons';
@import 'mixins/hover';

:host {
display: inline-flex;
height: $x-large-space;
font-size: $font-size-default;
font-weight: $font-weight-normal;
min-width: $x-large-space;

.link-button {
display: inline-flex;
position: relative;
width: 100%;
padding: 0 $tiny-space 0 0;
align-items: center;
justify-content: center;
background-color: transparent;
color: var(--theme-color-primary);
cursor: pointer;
text-decoration: none;

.link {
display: block;
position: relative;
width: 100%;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}

@include hover {
color: var(--theme-color-dynamic--hover);

.link {
text-decoration: underline;
text-underline-offset: 0.2rem;
}
}

@include active {
color: var(--theme-color-dynamic--active);

.link {
text-decoration: underline;
text-underline-offset: 0.2rem;
}
}

&.disabled {
cursor: default;
color: var(--theme-color-weak-text);
}

a {
all: unset;
}
}

:focus-visible {
outline: 1px solid var(--theme-color-focus-bdr);
}
}
Loading

0 comments on commit d98cabc

Please sign in to comment.