Skip to content

Commit

Permalink
Merge branch 'next' into chore/ts-react
Browse files Browse the repository at this point in the history
  • Loading branch information
AykutSarac authored Oct 17, 2023
2 parents 58efbd4 + caa388c commit fd0e485
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ body:
attributes:
label: Baklava Version
description: What version of Baklava are you using?
placeholder: 2.1.0-beta.7
placeholder: 2.3.0-beta.7
validations:
required: false
- type: textarea
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Web implementation of the design system is created as native web components so i
Preferred way of using Baklava is using it via CDN. Just import library JS and CSS files to your main document like below:

```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.2.0/dist/themes/default.css" />
<script type="module" src="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.2.0/dist/baklava.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.3.0/dist/themes/default.css" />
<script type="module" src="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.3.0/dist/baklava.js"></script>
```

This way library will be served from a very high performant CDN and all of the Baklava web components will be ready to use inside your web project.
Expand Down
6 changes: 3 additions & 3 deletions docs/customizing-baklava-theme.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ instead of `themes/default.css` file. Like:

```html
<link rel="stylesheet" href="/styles/my-baklava-theme.css" />
<script type="module" src="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.1.0/dist/baklava.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.3.0/dist/baklava.js"></script>
```

With this opportunity you can use all of the Baklava components with your own branding colors, own selection of Font or different sizing values.
Expand All @@ -29,9 +29,9 @@ With this opportunity you can use all of the Baklava components with your own br
If you want to change a small set of the design tokens, you may consider to extend default theme.

```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.1.0/dist/themes/default.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.3.0/dist/themes/default.css" />
<link rel="stylesheet" href="/styles/my-baklava-theme.css" />
<script type="module" src="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.1.0/dist/baklava.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.3.0/dist/baklava.js"></script>
```

With this, you can -for example- only override color palette for your app and continue to use typography or spacing rules from the default theme.
Expand Down
65 changes: 62 additions & 3 deletions docs/using-baklava-in-react.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ npm install @trendyol/baklava
Include Baklava library from CDN to your project's `index.html` file's `<head>` section.

```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.1.0/dist/themes/default.css"/>
<script type="module" src="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.1.0/dist/baklava.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.3.0/dist/themes/default.css"/>
<script type="module" src="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.3.0/dist/baklava.js"></script>
```

Then you can use Baklava React components in your project by importing them from `@trendyol/baklava/dist/baklava-react` in your code.
Expand Down Expand Up @@ -62,7 +62,7 @@ import ReactDOM from "react-dom/client";
import "@trendyol/baklava";
import { setIconPath } from "@trendyol/baklava";
import "@trendyol/baklava/dist/themes/default.css";
setIconPath("https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.1.0/dist/assets");
setIconPath("https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.3.0/dist/assets");

import App from "./App";

Expand Down Expand Up @@ -160,3 +160,62 @@ function MyComponent() {

export default MyComponent;
```

## Testing with Vitest

Baklava uses ES modules. We will explain how to install Vitest due to its ES Modules support. If you are using Jest,
your version should be greater than 26.5.0, and you should add "@trendyol/baklava" to the
[transformIgnorePatterns](https://jestjs.io/docs/tutorial-react-native#transformignorepatterns-customization).

```shell
npm install -D vitest vitest-dom jsdom
```

After downloading Vitest with this command, you should provide a file path to the setupFiles section in your
Vitest config file. We used './src/setupTest.ts'.

```js
import {defineConfig} from "vitest/config";

export default defineConfig({
test: {
...otherProps,
environment: "jsdom",
setupFiles: ["./src/setupTest.ts"]
}
});
```

Afterward, we should edit our setupTest.ts file just like setting up baklava.

```js
import "vitest-dom/extend-expect";
import "@trendyol/baklava";
import { setIconPath } from "@trendyol/baklava";
import "@trendyol/baklava/dist/themes/default.css";
setIconPath("https://cdn.jsdelivr.net/npm/@trendyol/[email protected]/dist/assets");
```

We are ready to write tests.

```tsx
import { fireEvent, render, screen } from "@testing-library/react";
import { expect, test, vi } from "vitest";
import { BlButton } from "@trendyol/baklava/dist/baklava-react";
import React from "react";

test("should trigger click event", async () => {
const onClickFn = vi.fn();
render(
<React.Suspense fallback={null}>
<BlButton onBlClick={onClickFn}>Button</BlButton>
</React.Suspense>
);

const blButton = await screen.findByText("Button");
const button = blButton.shadowRoot!.querySelector("button")!;
fireEvent.click(button);

expect(onClickFn).toBeCalled();
});
```
6 changes: 3 additions & 3 deletions docs/using-baklava-in-vue.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ To make the rule more generic, easiest way is ignoring the elements start with `
To be able to use Baklava via CDN, you should add our default.css and baklava.js at head tag in your index.html file.

```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.1.0/dist/themes/default.css"/>
<script type="module" src="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.1.0/dist/baklava.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.3.0/dist/themes/default.css"/>
<script type="module" src="https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.3.0/dist/baklava.js"></script>
```

### Via NPM
Expand All @@ -29,7 +29,7 @@ then,
```js
@import "@trendyol/baklava/dist/themes/default.css";
import { setIconPath } from '@trendyol/baklava'
setIconPath('https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.1.0/dist/assets')
setIconPath('https://cdn.jsdelivr.net/npm/@trendyol/baklava@2.3.0/dist/assets')
```

#### Vue2
Expand Down
7 changes: 4 additions & 3 deletions src/components/icon/icon-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ const icons = [
"chart",
"chatbot",
"check",
"clock",
"check_fill",
"clock",
"close",
"code",
"close_fill",
"code",
"coin",
"compass",
"complain",
Expand Down Expand Up @@ -74,8 +74,8 @@ const icons = [
"global_export",
"globe",
"go_forward",
"graphic_decrease",
"graphic",
"graphic_decrease",
"group_of_people",
"growth",
"hamburger_menu",
Expand Down Expand Up @@ -166,6 +166,7 @@ const icons = [
"puzzle",
"qr",
"report",
"review",
"rocket",
"rotate",
"sad",
Expand Down
3 changes: 3 additions & 0 deletions src/components/icon/icons/review.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fd0e485

Please sign in to comment.