Skip to content

Commit

Permalink
Merge pull request #7 from Jurfest/feature/utils
Browse files Browse the repository at this point in the history
feature/utils
  • Loading branch information
Jurfest authored Jun 20, 2024
2 parents 26182f5 + ac6cbde commit 12dfc97
Show file tree
Hide file tree
Showing 91 changed files with 1,920 additions and 1,801 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/storybook-chromatic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deploy Storybook to Chromatic

on:
push:
branches:
- main

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

# Install dependencies based on the package-lock.json file for reliability and speed
- name: Install dependencies
run: npm ci

# Optional: Uncomment the build-storybook step to apply custom build steps or to verify the build beforehand
# - name: Build Storybook
# run: npm run build-storybook

# Deploy Storybook using Chromatic's streamlined process (includes building the Storybook
- name: Deploy Storybook
run: npx chromatic
env:
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Toon Galaxy

https://66739ea5b581c33ced2d5fbc-jokebfyntt.chromatic.com/

## 🔬 Toon Galaxy Atomic Design System

The Toon Galaxy Atomic Design System is an integral part of the Toon Galaxy project. It follows the principles of Atomic Design for it's Components, ensuring a scalable and maintainable UI component library.
Expand Down
5 changes: 3 additions & 2 deletions apps/toon-galaxy/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { CharacterFacade } from '@toon-galaxy/toon-galaxy/domain';
styleUrl: './app.component.scss',
})
export class AppComponent {
title = 'toon-galaxy';
private characterFacade = inject(CharacterFacade);
totalFavoriteCharacters$ = this.characterFacade.totalFavoriteCharacters$;

readonly totalFavoriteCharacters$ =
this.characterFacade.totalFavoriteCharacters$;
}
21 changes: 16 additions & 5 deletions apps/toon-galaxy/src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import { provideRouter } from '@angular/router';
import { provideEffects } from '@ngrx/effects';
import { provideStore } from '@ngrx/store';
import { provideStoreDevtools } from '@ngrx/store-devtools';
import {
headerInterceptor,
loadingInterceptor,
provideSharedUtilCommon,
} from '@toon-galaxy/shared/util-common';
import { provideToonGalaxyDomain } from '@toon-galaxy/toon-galaxy/domain';

import { appRoutes } from './app.routes';
Expand All @@ -29,7 +34,10 @@ export const appConfig: ApplicationConfig = {
* withInterceptorsFromDi, as support for DI-provided interceptors may
* be phased out in a later release.
*/
provideHttpClient(withInterceptors([]), withFetch()),
provideHttpClient(
withInterceptors([loadingInterceptor, headerInterceptor]),
withFetch(),
),
provideClientHydration(),
provideRouter(
appRoutes,
Expand All @@ -45,14 +53,17 @@ export const appConfig: ApplicationConfig = {
),
provideAnimationsAsync(),

// NgRx
/**
* NgRx
* It's recommended to use provideState to register features - while the
* provideStore can be keep empty
*/
provideStore(),
provideEffects([]),
...(isDevMode() ? [provideStoreDevtools()] : []),
// provideState(),

//
// Character State Feature and Effect
provideToonGalaxyDomain(),
provideSharedUtilCommon(),

// Perform initialization, has to be last
{
Expand Down
Binary file added fonts/Poppins-SemiBold.ttf
Binary file not shown.
6 changes: 6 additions & 0 deletions libs/shared/ui-design-system/.storybook/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// import { addons } from '@storybook/manager-api';
// import { themes } from '@storybook/theming';

// addons.setConfig({
// theme: themes.dark,
// });
5 changes: 5 additions & 0 deletions libs/shared/ui-design-system/.storybook/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@
href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap"
rel="stylesheet"
/>

<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet"
/>
22 changes: 17 additions & 5 deletions libs/shared/ui-design-system/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { Preview } from '@storybook/angular';
import { themes } from '@storybook/theming';

export const parameters = {
docs: themes.dark,
};
// import { themes } from '@storybook/theming';

const preview: Preview = {
parameters: {
Expand All @@ -17,6 +13,22 @@ const preview: Preview = {
// storySort: {
// order: ['Intro', 'Pages', ['Home', 'Login', 'Admin'], 'Components'],
// },
backgrounds: {
default: 'dark',
values: [
{
name: 'dark',
value: '#1f1f1f',
},
{
name: 'gray',
value: '#CACACA',
},
],
},
// docs: {
// theme: themes.dark,
// },
},
};

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions libs/shared/ui-design-system/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ export * from './lib/tokens/line-heights';
export * from './lib/tokens/radii';
export * from './lib/tokens/space';

export * from './lib/components/atoms/heading/heading.component';
export * from './lib/components/atoms/input/input.component';
export * from './lib/components/atoms/icon/icon.component';
export * from './lib/components/atoms/input/input.component';
export * from './lib/components/atoms/button/button.component';
export * from './lib/components/atoms/heading/heading.component';
export * from './lib/components/atoms/spinner/spinner.component';

export * from './lib/components/molecules/empty-result/empty-result.component';

export * from './lib/components/organisms/navbar/navbar.component';
export * from './lib/components/organisms/card-list/card-list.component';
Original file line number Diff line number Diff line change
@@ -1,78 +1,46 @@
import { importProvidersFrom } from '@angular/core';
import {
BrowserAnimationsModule,
provideAnimations,
} from '@angular/platform-browser/animations';
import {
applicationConfig,
Meta,
moduleMetadata,
StoryObj,
} from '@storybook/angular';
import { expect, within } from '@storybook/test';

import { ButtonComponent } from './button.component';
import { Meta, moduleMetadata, StoryObj } from '@storybook/angular';
import { MatButtonModule } from '@angular/material/button';

// const meta: Meta<ButtonComponent> = {
// component: ButtonComponent,
// title: 'Design System/Atoms/Button',
// decorators: [
// // Apply application config to all stories
// applicationConfig({
// // List of providers and environment providers that should be available to the root component and all its children.
// providers: [
// // Import application-wide providers from a module
// importProvidersFrom(BrowserAnimationsModule),
// // Or use provide-style functions if available instead, e.g.
// provideAnimations(),
// ],
// }),
// ],
// args: {
// label: 'Button',
// },
// };
// export default meta;

// type Story = StoryObj<ButtonComponent>;

// export const Primary: Story = {};

// export const Heading: Story = {
// play: async ({ canvasElement }) => {
// const canvas = within(canvasElement);
// expect(canvas.getByText(/Button/gi)).toBeTruthy();
// },
// };

const Template = (args: ButtonComponent) => ({
props: args,
});
import { ButtonComponent } from './button.component';
import { IconComponent } from '../icon/icon.component';

export default {
title: 'Design System/Atoms/Button',
component: ButtonComponent,
title: 'Design System/Atoms/Button',
tags: ['autodocs'],
// decorators: [
// moduleMetadata({
// imports: [MatButtonModule],
// }),

// // Apply application config to all stories
// applicationConfig({
// // List of providers and environment providers that should be available to the root component and all its children.
// providers: [
// // Import application-wide providers from a module
// importProvidersFrom(BrowserAnimationsModule),
// // Or use provide-style functions if available instead, e.g.
// provideAnimations(),
// ],
// }),
// ],
decorators: [
moduleMetadata({
imports: [MatButtonModule, IconComponent],
}),
],
} as Meta;

type ButtonStory = StoryObj<ButtonComponent>;

export const Default: ButtonStory = {
render: (args) => ({
props: args,
template: `
<design-system-button (buttonClickEvent)="onClick($event)">
Voltar ao início
</design-system-button>
`,
}),
};

export const Default = Template.bind({});
Default.args = {
label: 'Button label',
export const WithIconAtRight: ButtonStory = {
render: (args) => ({
props: args,
template: `
<design-system-button (buttonClickEvent)="onClick($event)">
Click me with icon
<design-system-icon iconName="home" data-testid="home-icon"></design-system-icon>
</design-system-button>
`,
}),
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
expect(canvas.getByTestId(/home-icon/gi)).toBeTruthy();
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as ButtonStories from './button.component.stories';

<Canvas of={ButtonStories.Default} />

{/* <Canvas of={ButtonStories.WithIcon} /> */}
<Canvas of={ButtonStories.WithIconAtRight} />

## Getting started

Expand All @@ -22,12 +22,14 @@ You can implement the Button component by importing the `ButtonComponent` into y
import { ButtonComponent } from '@toon-galaxy/shared/ui-design-system/button';
```

The button has one required attribute: `label`. The `label` specifies the button label text as a string.
You can also optionally configure a type of button by specifying a `type` attribute on the button.
The button uses content projection (`ng-content`) to allow you to pass any content inside the button.

## Usage guidelines

Avoid using the button as a link and vice-versa. Provide semantic labels that give users an idea of the action behind the button &mdash; Try to be more specific than `"New"` or `"Save"`; use labels like
`Create new item` or `Update item`. Prefer using `primary` for main actions and `secondary` for less prominent actions.
Avoid using the button as a link and vice-versa. Provide semantic labels that give users an idea of the action behind
the button &mdash; Try to be more specific than `"New"` or `"Save"`; use labels like `Create new item` or
`Update item`. Prefer using `primary` for main actions and `secondary` for less prominent actions.

## Component API

<Controls />
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
<h1>Colors</h1>

<p>These are the colors used in Toon Galaxy UI</p>
<div class="bg-gradient-to-r from-green-300 to-blue-300 p-6 mb-10 rounded-lg">
<!-- <h1
class="text-6xl bg-gradient-to-r from-pink-400 to-indigo-500 bg-clip-text text-transparent"
>
Colors
</h1> -->
<h1 class="text-6xl bg-gradient-to-r text-color-neutral-surface">Colors</h1>
<p class="text-neutral-100 text-5xl tracking-tight mb-3">
These are the colors used in Toon Galaxy UI:
</p>
</div>

@for (colorObj of colorObjList; track colorObj.key) {
<div
[ngStyle]="{ '--dynamic-color': colorObj.color }"
class="dynamic-background"
class="bg-dynamic p-4 rounded-lg mb-4"
>
<div
class="color-description"
[ngClass]="{
custom: colorObj.labelColor === '#000',
}"
class="flex justify-between items-center text-white"
[ngClass]="{ 'text-black': colorObj.labelColor === '#000' }"
>
<strong>${{ colorObj.key }}</strong>
<span>{{ colorObj.color }}</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
.dynamic-background {
:host {
display: block;
}

.bg-dynamic {
background-color: var(--dynamic-color);
padding: 2rem;
border-radius: 0.5rem;
margin-bottom: 1rem;
}

.color-description {
display: flex;
justify-content: space-between;
flex-direction: row;
.text-white {
color: #fff;
}

// .custom {
// color: #000;
// }

&.custom {
color: #000;
}
.text-black {
color: #000;
}

// .gradient-text {
// background: linear-gradient(90deg, #ff6ec4, #7873f5);
// -webkit-background-clip: text;
// -webkit-text-fill-color: transparent;
// background-clip: text;
// text-fill-color: transparent;
// animation: gradient-animation 3s infinite;
// }

// @keyframes gradient-animation {
// 0% {
// background-position: 0% 50%;
// }
// 50% {
// background-position: 100% 50%;
// }
// 100% {
// background-position: 0% 50%;
// }
// }
Loading

0 comments on commit 12dfc97

Please sign in to comment.