Skip to content
Snippets Groups Projects
Commit 305063f6 authored by Markus Kaarto's avatar Markus Kaarto
Browse files

Merge branch 'development'

parents d1c48f4a 595b3801
No related branches found
No related tags found
No related merge requests found
Showing
with 670 additions and 2500 deletions
--- ---
## /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 expandtab smarttab autoindent: */ ## /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 expandtab smarttab autoindent: */
default: default:
image: "node:12.16.1" image: 'node:12.16.1'
cache: cache:
paths: paths:
- "node_modules/" - 'node_modules/'
stages: stages:
- build - build
...@@ -20,9 +20,9 @@ build: ...@@ -20,9 +20,9 @@ build:
when: always when: always
artifacts: artifacts:
paths: paths:
- "node_modules/" - 'node_modules/'
- "dist/" - 'dist/'
- "www/" - 'www/'
untracked: true untracked: true
script: script:
- yarn "install" --immutable - yarn "install" --immutable
...@@ -36,7 +36,7 @@ test: ...@@ -36,7 +36,7 @@ test:
when: on_success when: on_success
script: script:
- yarn "test" - yarn "test"
deploy_npm: deploy_npm:
stage: deploy stage: deploy
rules: rules:
......
{
"trailingComma": "none",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"bracketSpacing": false,
"printWidth": 120
}
/**
* This is an autogenerated file created by the Stencil compiler.
* DO NOT MODIFY IT MANUALLY
*/
export interface JsonDocs {
components: JsonDocsComponent[];
timestamp: string;
compiler: {
name: string;
version: string;
typescriptVersion: string;
};
}
export interface JsonDocsComponent {
dirPath?: string;
fileName?: string;
filePath?: string;
readmePath?: string;
usagesDir?: string;
encapsulation: 'shadow' | 'scoped' | 'none';
tag: string;
readme: string;
docs: string;
docsTags: JsonDocsTag[];
usage: JsonDocsUsage;
props: JsonDocsProp[];
methods: JsonDocsMethod[];
events: JsonDocsEvent[];
listeners: JsonDocsListener[];
styles: JsonDocsStyle[];
slots: JsonDocsSlot[];
parts: JsonDocsPart[];
dependents: string[];
dependencies: string[];
dependencyGraph: JsonDocsDependencyGraph;
deprecation?: string;
}
export interface JsonDocsDependencyGraph {
[tagName: string]: string[];
}
export interface JsonDocsTag {
name: string;
text?: string;
}
export interface JsonDocsValue {
value?: string;
type: string;
}
export interface JsonDocsUsage {
[key: string]: string;
}
export interface JsonDocsProp {
name: string;
type: string;
mutable: boolean;
attr?: string;
reflectToAttr: boolean;
docs: string;
docsTags: JsonDocsTag[];
default: string;
deprecation?: string;
values: JsonDocsValue[];
optional: boolean;
required: boolean;
}
export interface JsonDocsMethod {
name: string;
docs: string;
docsTags: JsonDocsTag[];
deprecation?: string;
signature: string;
returns: JsonDocsMethodReturn;
parameters: JsonDocMethodParameter[];
}
export interface JsonDocsMethodReturn {
type: string;
docs: string;
}
export interface JsonDocMethodParameter {
name: string;
type: string;
docs: string;
}
export interface JsonDocsEvent {
event: string;
bubbles: boolean;
cancelable: boolean;
composed: boolean;
docs: string;
docsTags: JsonDocsTag[];
deprecation?: string;
detail: string;
}
export interface JsonDocsStyle {
name: string;
docs: string;
annotation: string;
}
export interface JsonDocsListener {
event: string;
target?: string;
capture: boolean;
passive: boolean;
}
export interface JsonDocsSlot {
name: string;
docs: string;
}
export interface JsonDocsPart {
name: string;
docs: string;
}
export interface StyleDoc {
name: string;
docs: string;
annotation: 'prop';
}
declare const _default: JsonDocs;
export default _default;
This diff is collapsed.
...@@ -34,7 +34,10 @@ ...@@ -34,7 +34,10 @@
"jest-axe": "^3.4.0", "jest-axe": "^3.4.0",
"jest-cli": "26.0.1", "jest-cli": "26.0.1",
"puppeteer": "3.1.0", "puppeteer": "3.1.0",
"stylelint-config-recommended": "^3.0.0" "stylelint-config-recommended": "^3.0.0",
"husky": "4.2.5",
"prettier": "2.0.5",
"pretty-quick": "2.0.1"
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
...@@ -50,5 +53,10 @@ ...@@ -50,5 +53,10 @@
}, },
"browserslist": [ "browserslist": [
"last 2 versions" "last 2 versions"
] ],
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
}
} }
This diff is collapsed.
...@@ -4,15 +4,15 @@ ...@@ -4,15 +4,15 @@
.hy-accordion__item { .hy-accordion__item {
margin-bottom: 1rem; margin-bottom: 1rem;
transition: all .25s ease-in-out; transition: all 0.25s ease-in-out;
&__is-open { &__is-open {
$border-color: var(--grayscale-dark); $border-color: var(--grayscale-dark);
@include border-without-corners($border-color, 2px); @include border-without-corners($border-color, 2px);
margin-left: -1rem; margin-left: -1rem;
margin-right: -1rem; margin-right: -1rem;
transition: all .25s ease-in-out; transition: all 0.25s ease-in-out;
@include breakpoint($medium) { @include breakpoint($medium) {
margin-left: -2rem; margin-left: -2rem;
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
.hy-accordion--heading { .hy-accordion--heading {
margin: 0 auto; margin: 0 auto;
width: calc(100% - 2.25rem); width: calc(100% - 2.25rem);
transition: all .25s ease-in-out; transition: all 0.25s ease-in-out;
@include breakpoint($medium) { @include breakpoint($medium) {
width: calc(100% - 4.25rem); width: calc(100% - 4.25rem);
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
.hy-accordion--heading__icon { .hy-accordion--heading__icon {
transform: rotateX(180deg); transform: rotateX(180deg);
} }
} }
} }
} }
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
letter-spacing: -0.69px; letter-spacing: -0.69px;
line-height: 28px; line-height: 28px;
margin: 0 auto; margin: 0 auto;
transition: all .25s ease-in-out; transition: all 0.25s ease-in-out;
width: 100%; width: 100%;
.hy-accordion__button { .hy-accordion__button {
...@@ -57,8 +57,8 @@ ...@@ -57,8 +57,8 @@
font-weight: 600; font-weight: 600;
height: 100%; height: 100%;
justify-content: flex-start; justify-content: flex-start;
padding: .75rem 1.75rem .75rem 1.25rem; padding: 0.75rem 1.75rem 0.75rem 1.25rem;
transition: all .35s ease-in; transition: all 0.35s ease-in;
width: 100%; width: 100%;
&:hover { &:hover {
...@@ -71,19 +71,19 @@ ...@@ -71,19 +71,19 @@
line-height: 32px; line-height: 32px;
} }
&[aria-expanded=true] { &[aria-expanded='true'] {
background: none; background: none;
border-bottom: 1px solid var(--grayscale-medium-dark); border-bottom: 1px solid var(--grayscale-medium-dark);
border-left: 0; border-left: 0;
border-right: 0; border-right: 0;
border-top: 0; border-top: 0;
padding: .85rem 1rem 1rem 1rem; padding: 0.85rem 1rem 1rem 1rem;
transition: all .35s ease-in; transition: all 0.35s ease-in;
} }
} }
.hy-accordion--heading__icon { .hy-accordion--heading__icon {
margin-right: .95rem; margin-right: 0.95rem;
z-index: -1; z-index: -1;
svg { svg {
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
height: 0; height: 0;
overflow: hidden; overflow: hidden;
padding: 0; padding: 0;
transition: all .25s ease-in-out; transition: all 0.25s ease-in-out;
&--inner-wrapper { &--inner-wrapper {
display: block; display: block;
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
} }
// decorative bottom border/shadow // decorative bottom border/shadow
&::after { &::after {
content: ""; content: '';
display: block; display: block;
border-bottom: 2px solid var(--additional-skyblue); border-bottom: 2px solid var(--additional-skyblue);
position: absolute; position: absolute;
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
} }
} }
hy-button[icon-right="hy-icon-arrow-right"] { hy-button[icon-right='hy-icon-arrow-right'] {
.primary { .primary {
.hy-button__text { .hy-button__text {
margin: 12px 0 12px 16px; margin: 12px 0 12px 16px;
...@@ -156,7 +156,7 @@ hy-button[icon-right="hy-icon-arrow-right"] { ...@@ -156,7 +156,7 @@ hy-button[icon-right="hy-icon-arrow-right"] {
} }
} }
hy-button[icon="hy-icon-arrow-left"] { hy-button[icon='hy-icon-arrow-left'] {
.primary { .primary {
.hy-button__text { .hy-button__text {
margin: 12px 16px 12px 0; margin: 12px 16px 12px 0;
......
import { Button } from "./button"; import {Button} from './button';
import { newSpecPage } from "@stencil/core/testing"; import {newSpecPage} from '@stencil/core/testing';
it("should render correctly without attributes", async () => { it('should render correctly without attributes', async () => {
const page = await newSpecPage({ const page = await newSpecPage({
components: [Button], components: [Button],
html: `<hy-button>Hello tests!</hy-button>`, html: `<hy-button>Hello tests!</hy-button>`
}); });
expect(page.root).toEqualHtml(` expect(page.root).toEqualHtml(`
<hy-button> <hy-button>
...@@ -17,43 +17,43 @@ it("should render correctly without attributes", async () => { ...@@ -17,43 +17,43 @@ it("should render correctly without attributes", async () => {
`); `);
}); });
it("should have classname matching the variant", async () => { it('should have classname matching the variant', async () => {
const page = await newSpecPage({ const page = await newSpecPage({
components: [Button], components: [Button],
html: `<hy-button variant="secondary">Hello icons!<hy-button>`, html: `<hy-button variant="secondary">Hello icons!<hy-button>`
}); });
const button = page.doc.querySelector("button.secondary"); const button = page.doc.querySelector('button.secondary');
expect(button).toBeTruthy(); expect(button).toBeTruthy();
}); });
it("should have classname matching the state", async () => { it('should have classname matching the state', async () => {
const page = await newSpecPage({ const page = await newSpecPage({
components: [Button], components: [Button],
html: `<hy-button disabled>I am disabled!<hy-button>`, html: `<hy-button disabled>I am disabled!<hy-button>`
}); });
const button = page.doc.querySelector("button"); const button = page.doc.querySelector('button');
expect(button).toHaveAttribute("disabled"); expect(button).toHaveAttribute('disabled');
}); });
it("should display an arrow element", async () => { it('should display an arrow element', async () => {
const page = await newSpecPage({ const page = await newSpecPage({
components: [Button], components: [Button],
html: `<hy-button html: `<hy-button
icon="hy-icon-arrow-left" icon="hy-icon-arrow-left"
>Hello icons!<hy-button>`, >Hello icons!<hy-button>`
}); });
const icon = page.doc.querySelector("span.hy-button__icon"); const icon = page.doc.querySelector('span.hy-button__icon');
expect(icon).toHaveClass("hy-button__icon"); expect(icon).toHaveClass('hy-button__icon');
}); });
it("supports icons on both sides", async () => { it('supports icons on both sides', async () => {
const page = await newSpecPage({ const page = await newSpecPage({
components: [Button], components: [Button],
html: `<hy-button html: `<hy-button
variant="secondary" variant="secondary"
icon="hy-icon-arrow-left" icon="hy-icon-arrow-left"
icon-right="hy-icon-arrow-right">Hello icons!<hy-button>`, icon-right="hy-icon-arrow-right">Hello icons!<hy-button>`
}); });
const icons = page.doc.querySelectorAll("span.hy-button__icon"); const icons = page.doc.querySelectorAll('span.hy-button__icon');
expect(icons.length).toBe(2); expect(icons.length).toBe(2);
}); });
import { Component, h, Prop, Host } from "@stencil/core"; import {Component, h, Prop, Host} from '@stencil/core';
import { ButtonVariants } from "../../utils/utils"; import {ButtonVariants} from '../../utils/utils';
import colors from "../../global/colors"; import colors from '../../global/colors';
const fillcolors = { const fillcolors = {
primary: colors.brandMain, primary: colors.brandMain,
secondary: "white", secondary: 'white'
}; };
@Component({ @Component({
tag: "hy-button", tag: 'hy-button',
styleUrl: "button.scss", styleUrl: 'button.scss',
shadow: false, shadow: false
}) })
export class Button { export class Button {
/** /**
* The element variant. Defaults to primary * The element variant. Defaults to primary
*/ */
@Prop() variant: ButtonVariants = "primary"; @Prop() variant: ButtonVariants = 'primary';
/** /**
* deprecated, use disabled boolean value * deprecated, use disabled boolean value
* */ * */
@Prop() state: "enabled" | "disabled" = "enabled"; @Prop() state: 'enabled' | 'disabled' = 'enabled';
/** /**
* Size (height) of the button. Normal: 44px, large: 48px * Size (height) of the button. Normal: 44px, large: 48px
*/ */
@Prop() size: "normal" | "large" = "normal"; @Prop() size: 'normal' | 'large' = 'normal';
/** /**
* Use this to programmatically disable the button, matches the native button functionality * Use this to programmatically disable the button, matches the native button functionality
*/ */
...@@ -32,7 +32,7 @@ export class Button { ...@@ -32,7 +32,7 @@ export class Button {
/** /**
* Set this on if an anchor tag is required instead of a button. * Set this on if an anchor tag is required instead of a button.
*/ */
@Prop() url?: string = ""; @Prop() url?: string = '';
/** /**
* Aria label for the element * Aria label for the element
*/ */
...@@ -50,35 +50,26 @@ export class Button { ...@@ -50,35 +50,26 @@ export class Button {
*/ */
@Prop() iconRight?: string; @Prop() iconRight?: string;
render() { render() {
const classAttributes = [ const classAttributes = ['hy-button', this.variant, this.state, 'size-' + this.size];
"hy-button",
this.variant,
this.state,
"size-" + this.size,
];
const iconFillColor = fillcolors[this.variant]; const iconFillColor = fillcolors[this.variant];
const target = this.isExternal ? "_blank" : "_self"; const target = this.isExternal ? '_blank' : '_self';
return this.url ? ( return this.url ? (
<Host icon-right="hy-icon-arrow-right" aria-label={this.ariaLabel}> <Host icon-right="hy-icon-arrow-right" aria-label={this.ariaLabel}>
<div style={{ display: "flex" }}> <div style={{display: 'flex'}}>
<a class={classAttributes.join(" ")} href={this.url} target={target}> <a class={classAttributes.join(' ')} href={this.url} target={target}>
<span class="hy-button__text"> <span class="hy-button__text">
<slot /> <slot />
</span> </span>
<span class="hy-button__icon"> <span class="hy-button__icon">
<hy-icon <hy-icon icon="hy-icon-arrow-right" fill={iconFillColor} size={13} />
icon="hy-icon-arrow-right"
fill={iconFillColor}
size={13}
/>
</span> </span>
</a> </a>
</div> </div>
</Host> </Host>
) : ( ) : (
<Host aria-label={this.ariaLabel}> <Host aria-label={this.ariaLabel}>
<button class={classAttributes.join(" ")} disabled={this.disabled}> <button class={classAttributes.join(' ')} disabled={this.disabled}>
{!!this.icon && ( {!!this.icon && (
<span class="hy-button__icon hy-button__icon--left"> <span class="hy-button__icon hy-button__icon--left">
<hy-icon icon={this.icon} fill={iconFillColor} size={13} /> <hy-icon icon={this.icon} fill={iconFillColor} size={13} />
......
...@@ -121,7 +121,6 @@ Well, it's a button. ...@@ -121,7 +121,6 @@ Well, it's a button.
<!-- Auto Generated Below --> <!-- Auto Generated Below -->
## Properties ## Properties
| Property | Attribute | Description | Type | Default | | Property | Attribute | Description | Type | Default |
...@@ -131,11 +130,10 @@ Well, it's a button. ...@@ -131,11 +130,10 @@ Well, it's a button.
| `icon` | `icon` | Icon to use on the left side | `string` | `undefined` | | `icon` | `icon` | Icon to use on the left side | `string` | `undefined` |
| `iconRight` | `icon-right` | Icon to use on the right side | `string` | `undefined` | | `iconRight` | `icon-right` | Icon to use on the right side | `string` | `undefined` |
| `isExternal` | `is-external` | Use only with url property. Sets the | `boolean` | `false` | | `isExternal` | `is-external` | Use only with url property. Sets the | `boolean` | `false` |
| `size` | `size` | Size (height) of the button. Normal: 44px, large: 48px | `"large" \| "normal"` | `"normal"` | | `size` | `size` | Size (height) of the button. Normal: 44px, large: 48px | `"large" \| "normal"` | `'normal'` |
| `state` | `state` | deprecated, use disabled boolean value | `"disabled" \| "enabled"` | `"enabled"` | | `state` | `state` | deprecated, use disabled boolean value | `"disabled" \| "enabled"` | `'enabled'` |
| `url` | `url` | Set this on if an anchor tag is required instead of a button. | `string` | `""` | | `url` | `url` | Set this on if an anchor tag is required instead of a button. | `string` | `''` |
| `variant` | `variant` | The element variant. Defaults to primary | `"primary" \| "secondary"` | `"primary"` | | `variant` | `variant` | The element variant. Defaults to primary | `"primary" \| "secondary"` | `'primary'` |
## Dependencies ## Dependencies
...@@ -144,12 +142,13 @@ Well, it's a button. ...@@ -144,12 +142,13 @@ Well, it's a button.
- [hy-icon](../icon) - [hy-icon](../icon)
### Graph ### Graph
```mermaid ```mermaid
graph TD; graph TD;
hy-button --> hy-icon hy-button --> hy-icon
style hy-button fill:#f9f,stroke:#333,stroke-width:4px style hy-button fill:#f9f,stroke:#333,stroke-width:4px
``` ```
---------------------------------------------- ---
Helsinki University Design System Helsinki University Design System
import { newSpecPage } from '@stencil/core/testing'; import {newSpecPage} from '@stencil/core/testing';
import { ColorBox } from './color-box'; import {ColorBox} from './color-box';
describe('color-box', () => { describe('color-box', () => {
it('renders', async () => { it('renders', async () => {
const page = await newSpecPage({ const page = await newSpecPage({
components: [ColorBox], components: [ColorBox],
html: `<color-box></color-box>`, html: `<color-box></color-box>`
}); });
expect(page.root).toEqualHtml(` expect(page.root).toEqualHtml(`
<color-box> <color-box>
......
import { Component, ComponentInterface, Host, h } from '@stencil/core'; import {Component, ComponentInterface, Host, h} from '@stencil/core';
@Component({ @Component({
tag: 'color-box', tag: 'color-box',
styleUrl: 'color-box.css', styleUrl: 'color-box.css',
shadow: true, shadow: true
}) })
export class ColorBox implements ComponentInterface { export class ColorBox implements ComponentInterface {
render() { render() {
return ( return (
<Host> <Host>
...@@ -14,5 +13,4 @@ export class ColorBox implements ComponentInterface { ...@@ -14,5 +13,4 @@ export class ColorBox implements ComponentInterface {
</Host> </Host>
); );
} }
} }
# color-box # color-box
<!-- Auto Generated Below --> <!-- Auto Generated Below -->
---
----------------------------------------------
Helsinki University Design System Helsinki University Design System
...@@ -18,11 +18,7 @@ The general formula of the column width for a known gutter width: ...@@ -18,11 +18,7 @@ The general formula of the column width for a known gutter width:
Padding between image and display edge: Margin width + 1/2 column width. Padding between image and display edge: Margin width + 1/2 column width.
Padding between text block and display edge: Margin width + 1 column width. Padding between text block and display edge: Margin width + 1 column width.
*/ */
@mixin calcComponentMargins( @mixin calcComponentMargins($gutterWidth, $marginWidth, $fullWidth: 100%) {
$gutterWidth,
$marginWidth,
$fullWidth: 100%
) {
&.hy-cta-liftup-image-text { &.hy-cta-liftup-image-text {
padding-left: calc(((#{$fullWidth} - #{$gutterWidth} * 11) / 12) / 2); padding-left: calc(((#{$fullWidth} - #{$gutterWidth} * 11) / 12) / 2);
padding-right: calc(((#{$fullWidth} - #{$gutterWidth} * 11) / 12)); padding-right: calc(((#{$fullWidth} - #{$gutterWidth} * 11) / 12));
...@@ -36,11 +32,7 @@ The general formula of the column width for a known gutter width: ...@@ -36,11 +32,7 @@ The general formula of the column width for a known gutter width:
Padding between image and display edge: Margin width + 1/2 column width. Padding between image and display edge: Margin width + 1/2 column width.
Padding between text block and display edge: Margin width + 1 column width. Padding between text block and display edge: Margin width + 1 column width.
*/ */
@mixin calcComponentMarginsReversed( @mixin calcComponentMarginsReversed($gutterWidth, $marginWidth, $fullWidth: 100%) {
$gutterWidth,
$marginWidth,
$fullWidth: 100%
) {
&.hy-cta-liftup-image-text { &.hy-cta-liftup-image-text {
padding-right: calc(((#{$fullWidth} - #{$gutterWidth} * 11) / 12) / 2); padding-right: calc(((#{$fullWidth} - #{$gutterWidth} * 11) / 12) / 2);
padding-left: calc(((#{$fullWidth} - #{$gutterWidth} * 11) / 12)); padding-left: calc(((#{$fullWidth} - #{$gutterWidth} * 11) / 12));
...@@ -82,7 +74,7 @@ The general formula of the column width for a known gutter width: ...@@ -82,7 +74,7 @@ The general formula of the column width for a known gutter width:
@include breakpoint($extrawide) { @include breakpoint($extrawide) {
@include calcComponentMarginsReversed($margin-narrow, $gutter-extrawide); @include calcComponentMarginsReversed($margin-narrow, $gutter-extrawide);
} }
} }
&__image-container { &__image-container {
flex: 1; flex: 1;
...@@ -116,7 +108,8 @@ The general formula of the column width for a known gutter width: ...@@ -116,7 +108,8 @@ The general formula of the column width for a known gutter width:
padding-left: 50px; padding-left: 50px;
position: relative; position: relative;
z-index: 99; z-index: 99;
-webkit-border-image: -webkit-linear-gradient(to bottom, var(--grayscale-medium-dark), rgba(0, 0, 0, 0)) 1 0 0 100%; -webkit-border-image: -webkit-linear-gradient(to bottom, var(--grayscale-medium-dark), rgba(0, 0, 0, 0)) 1 0 0
100%;
-moz-border-image: linear-gradient(to bottom, var(--grayscale-medium-dark), rgba(0, 0, 0, 0)) 1 0 0 100%; -moz-border-image: linear-gradient(to bottom, var(--grayscale-medium-dark), rgba(0, 0, 0, 0)) 1 0 0 100%;
-o-border-image: linear-gradient(to bottom, var(--grayscale-medium-dark), rgba(0, 0, 0, 0)) 1 0 0 100%; -o-border-image: linear-gradient(to bottom, var(--grayscale-medium-dark), rgba(0, 0, 0, 0)) 1 0 0 100%;
} }
...@@ -141,19 +134,19 @@ The general formula of the column width for a known gutter width: ...@@ -141,19 +134,19 @@ The general formula of the column width for a known gutter width:
&--left { &--left {
// Padding between text block and display edge: Margin width + 1 column width. // Padding between text block and display edge: Margin width + 1 column width.
@include breakpoint($medium) { @include breakpoint($medium) {
padding-right: calc(#{$margin-narrow} + ((100% - #{$gutter-narrow} * 11 ) / 12)); padding-right: calc(#{$margin-narrow} + ((100% - #{$gutter-narrow} * 11) / 12));
} }
@include breakpoint($extrawide) { @include breakpoint($extrawide) {
padding-right: calc(#{$margin-narrow} + ((100% - #{$gutter-extrawide} * 11 ) / 12)); padding-right: calc(#{$margin-narrow} + ((100% - #{$gutter-extrawide} * 11) / 12));
} }
} }
&--right { &--right {
// Padding between text block and display edge: Margin width + 1 column width. // Padding between text block and display edge: Margin width + 1 column width.
@include breakpoint($medium) { @include breakpoint($medium) {
padding-left: calc(#{$margin-narrow} + ((100% - #{$gutter-narrow} * 11 ) / 12)); padding-left: calc(#{$margin-narrow} + ((100% - #{$gutter-narrow} * 11) / 12));
} }
@include breakpoint($extrawide) { @include breakpoint($extrawide) {
padding-left: calc(#{$margin-narrow} + ((100% - #{$gutter-extrawide} * 11 ) / 12)); padding-left: calc(#{$margin-narrow} + ((100% - #{$gutter-extrawide} * 11) / 12));
} }
} }
...@@ -199,6 +192,6 @@ The general formula of the column width for a known gutter width: ...@@ -199,6 +192,6 @@ The general formula of the column width for a known gutter width:
} }
.hy-cta-liftup-image-text::after { .hy-cta-liftup-image-text::after {
content: ""; content: '';
clear: both; clear: both;
} }
\ No newline at end of file
import { Component, ComponentInterface, Prop, h } from '@stencil/core'; import {Component, ComponentInterface, Prop, h} from '@stencil/core';
@Component({ @Component({
tag: 'hy-cta-liftup-image-text', tag: 'hy-cta-liftup-image-text',
styleUrl: 'cta-liftup-image-text.scss', styleUrl: 'cta-liftup-image-text.scss',
shadow: true, shadow: true
}) })
export class CtaLiftupImageText implements ComponentInterface { export class CtaLiftupImageText implements ComponentInterface {
@Prop() imageRight: boolean = false; @Prop() imageRight: boolean = false;
@Prop() imageUrl: string = null; @Prop() imageUrl: string = null;
@Prop() imageAlt: string = ""; @Prop() imageAlt: string = '';
@Prop() textTitle?: string; @Prop() textTitle?: string;
@Prop() textDescription: string = null; @Prop() textDescription: string = null;
@Prop() mainUrl?: string; @Prop() mainUrl?: string;
...@@ -26,20 +26,20 @@ export class CtaLiftupImageText implements ComponentInterface { ...@@ -26,20 +26,20 @@ export class CtaLiftupImageText implements ComponentInterface {
render() { render() {
const classAttributes = [ const classAttributes = [
"hy-cta-liftup-image-text", 'hy-cta-liftup-image-text',
this.imageRight ? "hy-cta-liftup-image-text--right-image" : null this.imageRight ? 'hy-cta-liftup-image-text--right-image' : null
].join(" "); ].join(' ');
const contentClassAttributes = [ const contentClassAttributes = [
"hy-cta-liftup-image-text__text-container", 'hy-cta-liftup-image-text__text-container',
this.imageRight ? "hy-cta-liftup-image-text__text-container--left" : "hy-cta-liftup-image-text__text-container--right" this.imageRight
].join(" "); ? 'hy-cta-liftup-image-text__text-container--left'
: 'hy-cta-liftup-image-text__text-container--right'
].join(' ');
const imageRightClassAttributes = [ const imageRightClassAttributes = [
"hy-cta-liftup-image-text__image-container", 'hy-cta-liftup-image-text__image-container',
"hy-cta-liftup-image-text__image-container--right" 'hy-cta-liftup-image-text__image-container--right'
].join(" "); ].join(' ');
const imageLeftClassAttributes = [ const imageLeftClassAttributes = ['hy-cta-liftup-image-text__image-container'].join(' ');
"hy-cta-liftup-image-text__image-container"
].join(" ");
const imageLeft = !this.imageRight; const imageLeft = !this.imageRight;
const aspectRatioWidth = 4; const aspectRatioWidth = 4;
...@@ -47,21 +47,21 @@ export class CtaLiftupImageText implements ComponentInterface { ...@@ -47,21 +47,21 @@ export class CtaLiftupImageText implements ComponentInterface {
return ( return (
<div class={classAttributes}> <div class={classAttributes}>
{ imageLeft && {imageLeft && (
<div class={imageLeftClassAttributes}> <div class={imageLeftClassAttributes}>
<hy-image <hy-image
image-url={this.imageUrl} image-url={this.imageUrl}
image-alt={this.imageAlt} image-alt={this.imageAlt}
aspect-ratio-width={aspectRatioWidth} aspect-ratio-width={aspectRatioWidth}
aspect-ratio-height={aspectRatioHeight} aspect-ratio-height={aspectRatioHeight}
caption=""> caption=""
</hy-image> ></hy-image>
</div> </div>
} )}
<div class={contentClassAttributes}> <div class={contentClassAttributes}>
<div class="hy-cta-liftup-image-text__text-container__title">{ this.textTitle }</div> <div class="hy-cta-liftup-image-text__text-container__title">{this.textTitle}</div>
<div class="hy-cta-liftup-image-text__text-container__description">{ this.textDescription }</div> <div class="hy-cta-liftup-image-text__text-container__description">{this.textDescription}</div>
{this.mainUrl && {this.mainUrl && (
<div class="hy-cta-liftup-image-text__text-container__link"> <div class="hy-cta-liftup-image-text__text-container__link">
<hy-cta-link-button <hy-cta-link-button
link-content={this.mainUrlTitle} link-content={this.mainUrlTitle}
...@@ -70,8 +70,8 @@ export class CtaLiftupImageText implements ComponentInterface { ...@@ -70,8 +70,8 @@ export class CtaLiftupImageText implements ComponentInterface {
is-external={this.mainUrlIsExternal} is-external={this.mainUrlIsExternal}
/> />
</div> </div>
} )}
{this.standaloneUrl && {this.standaloneUrl && (
<div class="hy-cta-liftup-image-text__text-container__standalonelink"> <div class="hy-cta-liftup-image-text__text-container__standalonelink">
<hy-standalone-link <hy-standalone-link
link-content={this.standaloneUrlTitle} link-content={this.standaloneUrlTitle}
...@@ -80,8 +80,8 @@ export class CtaLiftupImageText implements ComponentInterface { ...@@ -80,8 +80,8 @@ export class CtaLiftupImageText implements ComponentInterface {
is-external={this.standaloneUrlIsExternal} is-external={this.standaloneUrlIsExternal}
/> />
</div> </div>
} )}
{this.standaloneUrl2 && {this.standaloneUrl2 && (
<div class="hy-cta-liftup-image-text__text-container__standalonelink"> <div class="hy-cta-liftup-image-text__text-container__standalonelink">
<hy-standalone-link <hy-standalone-link
link-content={this.standaloneUrlTitle2} link-content={this.standaloneUrlTitle2}
...@@ -90,19 +90,19 @@ export class CtaLiftupImageText implements ComponentInterface { ...@@ -90,19 +90,19 @@ export class CtaLiftupImageText implements ComponentInterface {
is-external={this.standaloneUrlIsExternal2} is-external={this.standaloneUrlIsExternal2}
/> />
</div> </div>
} )}
</div> </div>
{ this.imageRight && {this.imageRight && (
<div class={imageRightClassAttributes}> <div class={imageRightClassAttributes}>
<hy-image <hy-image
image-url={this.imageUrl} image-url={this.imageUrl}
image-alt={this.imageAlt} image-alt={this.imageAlt}
aspect-ratio-width={aspectRatioWidth} aspect-ratio-width={aspectRatioWidth}
aspect-ratio-height={aspectRatioHeight} aspect-ratio-height={aspectRatioHeight}
caption=""> caption=""
</hy-image> ></hy-image>
</div> </div>
} )}
</div> </div>
); );
} }
......
# hy-cta-liftup-image-text # hy-cta-liftup-image-text
<!-- Auto Generated Below --> <!-- Auto Generated Below -->
## Properties ## Properties
| Property | Attribute | Description | Type | Default | | Property | Attribute | Description | Type | Default |
...@@ -27,7 +24,6 @@ ...@@ -27,7 +24,6 @@
| `textDescription` | `text-description` | | `string` | `null` | | `textDescription` | `text-description` | | `string` | `null` |
| `textTitle` | `text-title` | | `string` | `undefined` | | `textTitle` | `text-title` | | `string` | `undefined` |
## Dependencies ## Dependencies
### Depends on ### Depends on
...@@ -37,6 +33,7 @@ ...@@ -37,6 +33,7 @@
- [hy-standalone-link](../standalone-link) - [hy-standalone-link](../standalone-link)
### Graph ### Graph
```mermaid ```mermaid
graph TD; graph TD;
hy-cta-liftup-image-text --> hy-image hy-cta-liftup-image-text --> hy-image
...@@ -47,6 +44,6 @@ graph TD; ...@@ -47,6 +44,6 @@ graph TD;
style hy-cta-liftup-image-text fill:#f9f,stroke:#333,stroke-width:4px style hy-cta-liftup-image-text fill:#f9f,stroke:#333,stroke-width:4px
``` ```
---------------------------------------------- ---
Helsinki University Design System Helsinki University Design System
import { Component, ComponentInterface, Prop, h } from "@stencil/core"; import {Component, ComponentInterface, Prop, h} from '@stencil/core';
@Component({ @Component({
tag: "hy-cta-link-button", tag: 'hy-cta-link-button',
styleUrl: "cta-link-button.scss", styleUrl: 'cta-link-button.scss',
shadow: true, shadow: true
}) })
export class CtaLinkButton implements ComponentInterface { export class CtaLinkButton implements ComponentInterface {
/** /**
* deprecated, use slot * deprecated, use slot
*/ */
@Prop() linkContent: string = ""; @Prop() linkContent: string = '';
@Prop() url?: string; @Prop() url?: string;
@Prop() ariaLabel?: string; @Prop() ariaLabel?: string;
@Prop() isExternal: boolean = false; @Prop() isExternal: boolean = false;
render() { render() {
const containerClassAttributes = ["hy-cta-link-button-container"].join(" "); const containerClassAttributes = ['hy-cta-link-button-container'].join(' ');
const classAttributes = ["hy-cta-link-button"]; const classAttributes = ['hy-cta-link-button'];
const textClassAttributes = ["hy-cta-link-button__text"].join(" "); const textClassAttributes = ['hy-cta-link-button__text'].join(' ');
const iconClassAttributes = ["hy-cta-link-button__link-icon"].join(" "); const iconClassAttributes = ['hy-cta-link-button__link-icon'].join(' ');
const target = this.isExternal ? "_blank" : "_self"; const target = this.isExternal ? '_blank' : '_self';
return ( return (
<span class={containerClassAttributes}> <span class={containerClassAttributes}>
<a <a aria-label={this.ariaLabel} class={classAttributes.join(' ')} href={this.url} target={target}>
aria-label={this.ariaLabel} <span class={textClassAttributes}>{this.linkContent.length === 0 ? <slot /> : this.linkContent}</span>
class={classAttributes.join(" ")}
href={this.url}
target={target}
>
<span class={textClassAttributes}>
{this.linkContent.length === 0 ? <slot /> : this.linkContent}
</span>
<span class={iconClassAttributes}> <span class={iconClassAttributes}>
<hy-icon icon={"hy-icon-arrow-right"} size={13} /> <hy-icon icon={'hy-icon-arrow-right'} size={13} />
</span> </span>
</a> </a>
</span> </span>
......
# hy-cta-link-button # hy-cta-link-button
<!-- Auto Generated Below --> <!-- Auto Generated Below -->
## Properties ## Properties
| Property | Attribute | Description | Type | Default | | Property | Attribute | Description | Type | Default |
| ------------- | -------------- | -------------------- | --------- | ----------- | | ------------- | -------------- | -------------------- | --------- | ----------- |
| `ariaLabel` | `aria-label` | | `string` | `undefined` | | `ariaLabel` | `aria-label` | | `string` | `undefined` |
| `isExternal` | `is-external` | | `boolean` | `false` | | `isExternal` | `is-external` | | `boolean` | `false` |
| `linkContent` | `link-content` | deprecated, use slot | `string` | `""` | | `linkContent` | `link-content` | deprecated, use slot | `string` | `''` |
| `url` | `url` | | `string` | `undefined` | | `url` | `url` | | `string` | `undefined` |
## Dependencies ## Dependencies
### Used by ### Used by
- [hy-cta-liftup-image-text](../cta-liftup-image-text) - [hy-cta-liftup-image-text](../cta-liftup-image-text)
### Depends on ### Depends on
- [hy-icon](../icon) - [hy-icon](../icon)
### Graph ### Graph
```mermaid ```mermaid
graph TD; graph TD;
hy-cta-link-button --> hy-icon hy-cta-link-button --> hy-icon
...@@ -33,6 +30,6 @@ graph TD; ...@@ -33,6 +30,6 @@ graph TD;
style hy-cta-link-button fill:#f9f,stroke:#333,stroke-width:4px style hy-cta-link-button fill:#f9f,stroke:#333,stroke-width:4px
``` ```
---------------------------------------------- ---
Helsinki University Design System Helsinki University Design System
import { newSpecPage } from "@stencil/core/testing"; import {newSpecPage} from '@stencil/core/testing';
import { HyBadge } from "./hy-badge"; import {HyBadge} from './hy-badge';
describe("hy-badge", () => { describe('hy-badge', () => {
it("renders", async () => { it('renders', async () => {
const page = await newSpecPage({ const page = await newSpecPage({
components: [HyBadge], components: [HyBadge],
html: `<hy-badge></hy-badge>`, html: `<hy-badge></hy-badge>`
}); });
expect(page.root).toEqualHtml(` expect(page.root).toEqualHtml(`
<hy-badge> <hy-badge>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment