Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Provider): rewrite to TypeScript #1436

Merged
merged 3 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import transform from 'gulp-transform'
import { transform as svgr } from '@svgr/core'
import prettier from 'prettier'
import globby from 'globby'
import { iconCase } from '../../../src/components/icon'
import { iconCase } from '../../../src/components/icon/IconHelpers'
import { asyncForEach } from '../../tools'
import { log } from '../../lib'
import { md5 } from '../../figma/helpers/docHelpers'
Expand Down
9 changes: 0 additions & 9 deletions packages/dnb-eufemia/src/components/form-row/FormRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,3 @@ Fieldset.defaultProps = {
useFieldset: false,
className: null,
}

export const prepareFormRowContext = (props) => {
if (typeof props.label_direction === 'undefined') {
props.label_direction = isTrue(props.vertical)
? 'vertical'
: props.label_direction
}
return props
}
15 changes: 15 additions & 0 deletions packages/dnb-eufemia/src/components/form-row/FormRowHelpers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { isTrue } from '../../shared/component-helper'

type FormRowProps = {
label_direction?: string
tujoworker marked this conversation as resolved.
Show resolved Hide resolved
vertical?: string
tujoworker marked this conversation as resolved.
Show resolved Hide resolved
}

export const prepareFormRowContext = (props: FormRowProps) => {
if (typeof props.label_direction === 'undefined') {
props.label_direction = isTrue(props.vertical)
? 'vertical'
: props.label_direction
}
return props
}
9 changes: 1 addition & 8 deletions packages/dnb-eufemia/src/components/icon/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
} from '../space/SpacingHelper'
import { createSkeletonClass } from '../skeleton/SkeletonHelper'
import Context from '../../shared/Context'
import { iconCase } from './IconHelpers'

export const DefaultIconSize = 16
export const DefaultIconSizes = {
Expand Down Expand Up @@ -446,11 +447,3 @@ export const prerenderIcon = ({
return null
}
}

// to replace icon names
export const iconCase = (name) =>
name
.replace(/((?!^)[A-Z])/g, '_$1')
.toLowerCase()
.replace(/^[0-9]/g, '$1')
.replace(/[^a-z0-9_]/gi, '_')
7 changes: 7 additions & 0 deletions packages/dnb-eufemia/src/components/icon/IconHelpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// to replace icon names
export const iconCase = (name) =>
name
.replace(/((?!^)[A-Z])/g, '_$1')
.toLowerCase()
.replace(/^[0-9]/g, '$1')
.replace(/[^a-z0-9_]/gi, '_')
16 changes: 9 additions & 7 deletions packages/dnb-eufemia/src/components/pagination/PaginationBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,28 @@ interface PaginationBarProps {
/**
* The title used in every button shown in the bar. Defaults to Side %s.
*/
button_title: string
button_title?: string
/**
* The title used in the previous page button. Defaults to Forrige side.
*/
prev_title: string
prev_title?: string
/**
* The title used in the next page button. Defaults to Neste side.
*/
next_title: string
next_title?: string
/**
* The title used in the dots. Relevant for screen-readers. Defaults to %s flere sider.
*/
more_pages: string
more_pages?: string
/**
* Reference to the parent component. Used to contain height between updates.
*/
contentRef: React.RefObject<any>
contentRef?: React.RefObject<HTMLElement>
/**
* the given content can be either a function or a React node, depending on your needs. A function contains several helper functions. More details down below and have a look at the examples in the demos section.
*/
children: React.ReactNode
children?: React.ReactNode
locale?: string
}

const defaultProps = {
Expand Down Expand Up @@ -134,7 +135,8 @@ const PaginationBar = (innerProps: PaginationBarProps) => {
extendPropsWithContext(
{ ...defaultProps, ...innerProps },
defaultProps,
getTranslation(innerProps).Pagination
getTranslation(innerProps as Pick<PaginationBarProps, 'locale'>)
.Pagination
)

const prevIsDisabled = currentPage > -1 ? currentPage === 1 : true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class AutoSize extends React.Component<AutoSizeProps, any> {
}
export interface SkeletonContextProps {
translation?: {
Skeleton: {
Skeleton?: {
/**
* Is used for screen reader text translation, defined in the translation files. You can set a custom text if needed.
*/
Expand Down
121 changes: 0 additions & 121 deletions packages/dnb-eufemia/src/shared/Context.js

This file was deleted.

Loading