From 4cc1a808dc8c17821931a15853283ee2521430bc Mon Sep 17 00:00:00 2001 From: Nicolae Tataru Date: Mon, 22 Feb 2021 11:30:40 +0200 Subject: [PATCH 1/6] Small fix of rowSpan on column table --- src/components/organisms/Table/Table.tsx | 27 ++++++++++++++---------- src/libs/object/object.ts | 2 ++ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/components/organisms/Table/Table.tsx b/src/components/organisms/Table/Table.tsx index fd25474f..fa255921 100644 --- a/src/components/organisms/Table/Table.tsx +++ b/src/components/organisms/Table/Table.tsx @@ -1,7 +1,9 @@ import * as React from 'react'; import cn from 'classnames'; import OldTable from 'rc-table'; +import { RenderedCell } from 'rc-table/lib/interface'; import { Icon } from 'components/atoms'; +import { isObject } from 'libs'; import { GenericObject } from 'types'; const types: ['desc', 'asc'] = ['desc', 'asc']; @@ -12,7 +14,7 @@ export interface Column { className?: string; width?: string | number; onFilter?: (type: 'asc' | 'desc') => void; - render?: (value: T) => React.ReactNode; + render?: (value: T, row: GenericObject, index: number) => React.ReactNode | RenderedCell; mobileRender?: (data: T) => React.ReactNode; children?: Column[]; action?: boolean; @@ -113,15 +115,20 @@ export const Table = ({ {data.map((item: any) => (
{item.key}
- {columns.map((column) => { + {columns.map((column, i) => { const render = column.mobileRender !== undefined - ? column.mobileRender(item as T) + ? column.mobileRender(item) : column.render !== undefined - ? column.render(item as T) + ? column.render(item, column, i) : column.dataIndex !== undefined - ? (item[column.dataIndex] as T) + ? item[column.dataIndex] : '---'; + const renderChildren = !isObject(render) + ? render + : !isObject(render.children) + ? render.children + : render.children[column.dataIndex!]; return ( @@ -138,14 +145,12 @@ export const Table = ({ > {column.key > 1 && {column.title}:} - {render} + {renderChildren}
) : ( - render && ( -
- {render} -
- ) +
+ {renderChildren} +
)} ); diff --git a/src/libs/object/object.ts b/src/libs/object/object.ts index e4b11d63..f36bd437 100644 --- a/src/libs/object/object.ts +++ b/src/libs/object/object.ts @@ -15,3 +15,5 @@ export const validate = (errors: string[] | { [key: string]: string[] }): string return []; }; + +export const isObject = (val: any): boolean => typeof val === 'object' From ab6cf0c531b202274902ec8b2cda238864a80a7d Mon Sep 17 00:00:00 2001 From: Nicolae Tataru Date: Mon, 22 Feb 2021 16:25:49 +0200 Subject: [PATCH 2/6] Fixed column render on table --- src/components/organisms/Table/Table.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/organisms/Table/Table.tsx b/src/components/organisms/Table/Table.tsx index fa255921..bdbfc2ce 100644 --- a/src/components/organisms/Table/Table.tsx +++ b/src/components/organisms/Table/Table.tsx @@ -126,9 +126,9 @@ export const Table = ({ : '---'; const renderChildren = !isObject(render) ? render - : !isObject(render.children) + : render && !isObject(render.children) ? render.children - : render.children[column.dataIndex!]; + : render && render.children[column.dataIndex!]; return ( From 17645210fa0c88af315824cae709f7c756d9cd56 Mon Sep 17 00:00:00 2001 From: Nicolae Tataru Date: Mon, 22 Feb 2021 17:37:01 +0200 Subject: [PATCH 3/6] Added media query for font-size until desktop & small-desktop, fixed basic font-size --- src/styles/global-styles.scss | 21 ++++++++++----------- src/styles/variables.scss | 5 +++++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/styles/global-styles.scss b/src/styles/global-styles.scss index 224bd79d..3059310b 100644 --- a/src/styles/global-styles.scss +++ b/src/styles/global-styles.scss @@ -8,21 +8,20 @@ html, body { - display: block; - font-size: $font-size-base; - line-height: $line-height-base; - color: $text-color; @include fontMedium; + display: block; margin: 0; + font-size: rem($font-size-base); + line-height: rem($line-height-base); + color: $text-color; - // TODO: Move to font-size to variables as responsive - // @include mq($until: desktop) { - // font-size: rem(13px); - // } + @include mq($until: desktop) { + font-size: rem(12.5px); + } - // @include mq($until: small-desktop) { - // font-size: rem(12px); - // } + @include mq($until: small-desktop) { + font-size: rem(10px); + } } * { diff --git a/src/styles/variables.scss b/src/styles/variables.scss index bcbec2ff..e3dc4756 100644 --- a/src/styles/variables.scss +++ b/src/styles/variables.scss @@ -40,6 +40,11 @@ $font-size-base: 14px !default; $font-size-sm: $font-size-base * 0.875 !default; $font-size-lg: $font-size-base * 1.25 !default; +// rems to pixels +$rem-baseline: $font-size-base !default; +$rem-fallback: true !default; +$rem-px-only: false !default; + $font-weight-light: 300 !default; $font-weight-normal: 400 !default; $font-weight-medium: 500 !default; From 7dee42c72311deaddd3dfe3aa456fd13b7644eb8 Mon Sep 17 00:00:00 2001 From: Nicolae Tataru Date: Mon, 22 Feb 2021 17:49:04 +0200 Subject: [PATCH 4/6] Removed unncesary variables --- src/styles/variables.scss | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/styles/variables.scss b/src/styles/variables.scss index e3dc4756..bcbec2ff 100644 --- a/src/styles/variables.scss +++ b/src/styles/variables.scss @@ -40,11 +40,6 @@ $font-size-base: 14px !default; $font-size-sm: $font-size-base * 0.875 !default; $font-size-lg: $font-size-base * 1.25 !default; -// rems to pixels -$rem-baseline: $font-size-base !default; -$rem-fallback: true !default; -$rem-px-only: false !default; - $font-weight-light: 300 !default; $font-weight-normal: 400 !default; $font-weight-medium: 500 !default; From e94f04e7f702e477657119dd9ea51000a796baff Mon Sep 17 00:00:00 2001 From: Nicolae Tataru Date: Mon, 22 Feb 2021 17:50:13 +0200 Subject: [PATCH 5/6] Small fix on rem to px --- src/styles/mixins/rem-to-px.scss | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/styles/mixins/rem-to-px.scss b/src/styles/mixins/rem-to-px.scss index 072e237a..f43a83d4 100644 --- a/src/styles/mixins/rem-to-px.scss +++ b/src/styles/mixins/rem-to-px.scss @@ -1,5 +1,4 @@ // rems to pixels -$rem-baseline: $font-size-base !default; $rem-fallback: true !default; $rem-px-only: false !default; @@ -20,9 +19,9 @@ $rem-px-only: false !default; $separator: rem-separator($values); @each $value in $values { @if type-of($value) == 'number' and unit($value) == 'rem' and $to== 'px' { - $result: append($result, $value / 1rem * $rem-baseline, $separator); + $result: append($result, $value / 1rem * $font-size-base, $separator); } @else if type-of($value) == 'number' and unit($value) == 'px' and $to== 'rem' { - $result: append($result, $value / ($rem-baseline / 1rem), $separator); + $result: append($result, $value / ($font-size-base / 1rem), $separator); } @else if type-of($value) == 'list' { $result: append($result, rem-convert($to, $value...), $separator); } @else { From 8eafeaba84557bfd2c74e986670454092b34d9c0 Mon Sep 17 00:00:00 2001 From: Nicolae Tataru Date: Mon, 22 Feb 2021 17:51:19 +0200 Subject: [PATCH 6/6] Up version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1a88b8e2..94333110 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ebs-integrator/react-ebs-ui", - "version": "0.0.1-beta.28", + "version": "0.0.1-beta.29", "description": "Basic React UI elements.", "author": "EBS Integrator", "maintainers": [