Skip to content

Commit

Permalink
fixes most of the console warnings, fixes some eslint errors, gets ri…
Browse files Browse the repository at this point in the history
…d of the formik and redux-form styleguidist sections in the UI
  • Loading branch information
ifrim committed Jan 8, 2022
1 parent f58ade2 commit 3984b90
Show file tree
Hide file tree
Showing 30 changed files with 295 additions and 246 deletions.
8 changes: 4 additions & 4 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Tyk-ui is library of reusable presentational UI components.
Tyk-ui is library of reusable presentational UI components.

### **Installation**

Expand Down Expand Up @@ -45,11 +45,11 @@ $component-images-path: "~@tyk-technologies/tyk-ui/lib/images/";
```md
NOTE : For projects that don't SASS but just pure css we are also exposing the compiled styles.
```
### Testing on local
### Testing on local

- You can test the changes on your local dev environment by replacing the your `@tyk-technologies/tyk-ui/lib` with newly built lib
- You can test the changes on your local dev environment by replacing the your `@tyk-technologies/tyk-ui/lib` with newly built lib

eg
eg
```md
cp -a lib/. /Users/me/go/src/github.com/TykTechnologies/tyk-analytics/webclient/node_modules/@tyk-technologies/tyk-ui/lib
```
14 changes: 7 additions & 7 deletions docs/PublishingGuide.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
*In order to publish the changes, please do the following*
- After PR merge, make a new build and generates prod code of the library

```static
```shell static
npm run build-prod
```

- Increase the library version in `package.json`

- Regenerate the `package-lock.json` file

```static
```shell static
npm i
```

```static
git add .
```shell static
git add .
```

- Commit and Push changes
```static
```shell static
git commit -m "bump version"
```

- Publish the package to npm
```static
npm publish
```shell static
npm publish
```
10 changes: 6 additions & 4 deletions src/common/sass/mixins.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use "sass:math";

@function theme-color($key: 'primary', $variant: 'base') {
$map: map-get($theme-colors, $key);
@return map-get($map, $variant);
Expand Down Expand Up @@ -50,12 +52,12 @@
@mixin grid-loop($name) {
@for $i from 0 through $grid-columns {
.tyk-col--#{$name}-#{$i} {
flex-basis: calc(#{percentage($i / $grid-columns)} - #{$grid-gutter});
max-width: calc(#{percentage($i / $grid-columns)} - #{$grid-gutter});
flex-basis: calc(#{percentage(math.div($i, $grid-columns))} - #{$grid-gutter});
max-width: calc(#{percentage(math.div($i, $grid-columns))} - #{$grid-gutter});
}

.tyk-col--offset-#{$name}-#{$i} {
margin-left: percentage($i / $grid-columns);
margin-left: percentage(math.div($i, $grid-columns));
}
}
}
Expand Down Expand Up @@ -95,7 +97,7 @@
opacity: 0.8;
}
}

&.tyk-form-group--addon-left {
.tyk-input-group__addon {
border-bottom: 2px solid $border-color;
Expand Down
18 changes: 9 additions & 9 deletions src/components/Table/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Table component depends on `value` prop which consist of following schema.

```json
{
"columns": [{}],
"columns": [{}],
"rows": [{}],
"selectable" : {},
"pagination": {
Expand Down Expand Up @@ -45,7 +45,7 @@ columns[n].sortable
```
- Gives sorting capabilities for to the table and can be extended to change the default sorting behavior.

eg.
eg.
```json

// Make table sortable
Expand All @@ -54,7 +54,7 @@ eg.
"sortable": true
}

// Make table sortable and change the default sortable direction to Ascending
// Make table sortable and change the default sortable direction to Ascending
"column" : {
//...
"sortable": {
Expand All @@ -68,7 +68,7 @@ eg.
rows[n].values
```

- Defines the the values to be rendered for the table. You can also pass props and values using this if your `columns[n].type` is a custom component.
- Defines the the values to be rendered for the table. You can also pass props and values using this if your `columns[n].type` is a custom component.
- Values is an object who's keys should match the `columns[n].id` for table to understand what values need to be rendered under what column
- You can consider rows[n].values[{yourColumnId}] as a single cell which you can completely customize

Expand Down Expand Up @@ -347,7 +347,7 @@ const config = {
};


<Table
<Table
value={config}
onChange={
(message, data, tableApi) => {
Expand All @@ -365,17 +365,17 @@ const config = {

You access the table api directly to `get` and `set` table state by accessing the third arg passed to `onChange`

- `api.getState`
- `api.getState`
To get current table state

- `api.setState`
To get current state of table

### FAQ's

#### 1. Can I attach an event to only one specific cell in the table
#### 1. Can I attach an event to only one specific cell in the table

Yes, you can add events or custom styles to a specific cell using `events` and `styling` for the cell.
Yes, you can add events or custom styles to a specific cell using `events` and `styling` for the cell.

Syntax
```js static
Expand All @@ -386,5 +386,5 @@ value.rows[index][col_id].events = {
```

```md
Note : Click on `Freemium Policy (A)` in the above interactive table example and check the developer console and rows config `(value.rows[0].values.name)` for code
Note : Click on `Freemium Policy (A)` in the above interactive table example and check the developer console and rows config `(value.rows[0].values.name)` for code
```
1 change: 1 addition & 0 deletions src/form/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
form components docs (wip)
6 changes: 4 additions & 2 deletions src/form/components/EditableList2/sass/EditableList2.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use "sass:math";

.editable-list {
&__header {
align-items: center;
Expand Down Expand Up @@ -75,7 +77,7 @@
&--size-#{$i} {
display: flex;
flex-grow: #{$i + 1};
$my_width: #{$i/12*100%};
$my_width: #{math.div($i, 12) * 100%};
width: $my_width;
}
}
Expand All @@ -97,7 +99,7 @@
&--read-only {
color: theme-color("default", "light");
align-items: center;

.tyk-button {
margin-top: 0;
}
Expand Down
1 change: 1 addition & 0 deletions src/hooks/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hooks docs (wip)
1 change: 1 addition & 0 deletions src/hooks/useComponentSize/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
useComponentSize docs
1 change: 1 addition & 0 deletions src/hooks/useComponentSize/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ const useComponentSize = (ref) => {
return ComponentSize;
};

/** @component */
export default useComponentSize;
1 change: 0 additions & 1 deletion src/hooks/useComponentSize/useComponentSize.md

This file was deleted.

1 change: 1 addition & 0 deletions src/hooks/useEventListener/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
useEventListener docs
1 change: 1 addition & 0 deletions src/hooks/useEventListener/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ const useEventListener = (eventName, handler, element) => {
}, [eventName, element]);
};

/** @component */
export default useEventListener;
1 change: 0 additions & 1 deletion src/hooks/useEventListener/useEventListener.md

This file was deleted.

1 change: 1 addition & 0 deletions src/hooks/useInterval/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
useInterval docs
1 change: 1 addition & 0 deletions src/hooks/useInterval/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useRef } from 'react';

/** @component */
export default function useInterval(callback, delay, ...args) {
const savedCallback = useRef();

Expand Down
1 change: 0 additions & 1 deletion src/hooks/useInterval/useInterval.md

This file was deleted.

1 change: 1 addition & 0 deletions src/hooks/usePrevious/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
usePrevious docs
1 change: 1 addition & 0 deletions src/hooks/usePrevious/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ const usePrevious = (value) => {
return ref.current;
};

/** @component */
export default usePrevious;
1 change: 0 additions & 1 deletion src/hooks/usePrevious/usePrevious.md

This file was deleted.

1 change: 1 addition & 0 deletions src/hooks/useTimeout/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
useTimeout docs
1 change: 1 addition & 0 deletions src/hooks/useTimeout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ const useTimeout = (callback, delay) => {
[delay]);
};

/** @component */
export default useTimeout;
File renamed without changes.
20 changes: 20 additions & 0 deletions src/utils/debounce/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
`debounce` "postpones" the execution of a callback after the specified amount of time in milliseconds.

```js static
debounce(callback, wait, immediate)
```

If you type in the text input below its value will be logged to the console.

```js
import DebounceExample from './styleguidist-example';

const [wait, setWait] = React.useState(1000);
<>
<label>
<span style={{ marginRight: '10px' }}>Wait:</span>
<input type="text" value={wait} onChange={e => setWait(e.target.value)} />
</label>
<DebounceExample wait={Number(wait)} />
</>
```
1 change: 0 additions & 1 deletion src/utils/debounce/debounce.md

This file was deleted.

26 changes: 26 additions & 0 deletions src/utils/debounce/styleguidist-example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import PropTypes from 'prop-types';

import debounce from './index';

function Debounce({ func, wait, immediate }) {
const cbb = (e) => {
console.log(`Debounced log after ${wait}ms:`, e.target.value);
};
return (
<div>
<label>
<span style={{ marginRight: '10px' }}>Type here (logs to the console):</span>
<input type="text" onChange={debounce(func ?? cbb, wait, immediate)} />
</label>
</div>
);
}

Debounce.propTypes = {
func: PropTypes.func,
wait: PropTypes.number,
immediate: PropTypes.bool,
};

export default Debounce;
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 3984b90

Please sign in to comment.