-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(data-table): add email and phone cells (#808)
* feat: add email and telephone data type to data grid cell * feat: add email and telephone data cell stories * chore: update dummy email and telephone number in story book * test: add email cell and phone cell spec tests Co-authored-by: Maomao Meyer-Zhang <[email protected]>
- Loading branch information
Showing
8 changed files
with
289 additions
and
171 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
packages/components/src/components/data-grid/cell-handlers/email-cell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @license | ||
* Scale https://github.com/telekom/scale | ||
* | ||
* Copyright (c) 2021 Egor Kirpichev and contributors, Deutsche Telekom AG | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import { h } from '@stencil/core'; | ||
import { Cell } from './cell-interface'; | ||
|
||
// Expected content: an email string (eg: 'mailto:[email protected]) | ||
|
||
export const EmailCell: Cell = { | ||
defaults: { | ||
sortBy: 'text', | ||
}, | ||
render: ({ content }) => { | ||
// Remove protocol (mailto:) | ||
const emailNoProtocol = content.replace(/^mailto:/i, ''); | ||
return <scale-link href={content}>{emailNoProtocol}</scale-link>; | ||
}, | ||
}; |
26 changes: 26 additions & 0 deletions
26
packages/components/src/components/data-grid/cell-handlers/telephone-cell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @license | ||
* Scale https://github.com/telekom/scale | ||
* | ||
* Copyright (c) 2021 Egor Kirpichev and contributors, Deutsche Telekom AG | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import { h } from '@stencil/core'; | ||
import { Cell } from './cell-interface'; | ||
|
||
// Expected content: a telephone number string (eg: 'tel:+491234567') | ||
|
||
export const TelephoneCell: Cell = { | ||
defaults: { | ||
sortBy: 'text', | ||
}, | ||
render: ({ content }) => { | ||
// Remove protocol (tell:) | ||
const telephoneNoProtocol = content.replace(/^tel:/i, ''); | ||
return <scale-link href={content}>{telephoneNoProtocol}</scale-link>; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.