-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upcoming: [M3-8638] - Introduce the new
(at)linode/ui
package (#11057)
* Introduce the new @linode/ui package * Feedback @bnussman-akamai * Move existing usages of to new package * Tweaks * Fix unnecessary prop on component * Add CHANGELOG.md for UI package * Added changeset: new `@linode/ui` package with `BetaChip` as the first component * Add UI typechecking step to ci.yml
- Loading branch information
1 parent
9dfa675
commit dbf2e0c
Showing
24 changed files
with
342 additions
and
8 deletions.
There are no files selected for viewing
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
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
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
2 changes: 1 addition & 1 deletion
2
packages/manager/src/features/Databases/DatabaseLanding/DatabaseLogo.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
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,18 @@ | ||
# Changesets | ||
|
||
This directory gets auto-populated when running `yarn changeset`. | ||
You can however add your changesets manually as well, knowing that the [TYPE] is limited to the following options `Added`, `Fixed`, `Changed`, `Removed`, `Tech Stories`, `Tests`, `Upcoming Features` and follow this format: | ||
|
||
```md | ||
--- | ||
"@linode/[PACKAGE]": [TYPE] | ||
--- | ||
|
||
My PR Description ([#`PR number`](`PR link`)) | ||
``` | ||
|
||
You must commit them to the repo so they can be picked up for the changelog generation. | ||
|
||
This directory get wiped out when running `yarn generate-changelog`. | ||
|
||
See `changeset.mjs` for implementation details. |
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,5 @@ | ||
--- | ||
"@linode/ui": Added | ||
--- | ||
|
||
new `@linode/ui` package with `BetaChip` as the first component ([#11057](https://github.com/linode/manager/pull/11057)) |
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,75 @@ | ||
{ | ||
"ignorePatterns": [ | ||
"node_modules", | ||
"lib", | ||
"index.js", | ||
"!.eslintrc.js" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 2020, | ||
"warnOnUnsupportedTypeScriptVersion": true | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"sonarjs", | ||
"prettier", | ||
"@linode/eslint-plugin-cloud-manager" | ||
], | ||
"extends": [ | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:sonarjs/recommended", | ||
"plugin:prettier/recommended" | ||
], | ||
"rules": { | ||
"no-unused-vars": [ | ||
"warn", | ||
{ | ||
"argsIgnorePattern": "^_" | ||
} | ||
], | ||
"no-unused-expressions": "warn", | ||
"no-bitwise": "error", | ||
"no-caller": "error", | ||
"no-eval": "error", | ||
"no-throw-literal": "warn", | ||
"no-loop-func": "error", | ||
"no-await-in-loop": "error", | ||
"array-callback-return": "error", | ||
"no-invalid-this": "off", | ||
"no-new-wrappers": "error", | ||
"no-restricted-imports": [ | ||
"error", | ||
"rxjs" | ||
], | ||
"no-console": "error", | ||
"no-undef-init": "off", | ||
"radix": "error", | ||
"@typescript-eslint/no-unused-vars": "off", | ||
"@typescript-eslint/no-inferrable-types": "off", | ||
"@typescript-eslint/no-namespace": "warn", | ||
"@typescript-eslint/camelcase": "off", | ||
"@typescript-eslint/explicit-function-return-type": "off", | ||
"@typescript-eslint/no-empty-interface": "warn", | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-use-before-define": "off", | ||
"@typescript-eslint/interface-name-prefix": "off", | ||
"sonarjs/cognitive-complexity": "warn", | ||
"sonarjs/no-duplicate-string": "warn", | ||
"sonarjs/prefer-immediate-return": "warn", | ||
"sonarjs/no-identical-functions": "warn", | ||
"sonarjs/no-redundant-jump": "warn", | ||
"sonarjs/no-small-switch": "warn", | ||
"no-multiple-empty-lines": "error", | ||
"curly": "warn", | ||
"sort-keys": "off", | ||
"comma-dangle": "off", | ||
"no-trailing-spaces": "warn", | ||
"no-mixed-requires": "warn", | ||
"spaced-comment": "warn", | ||
"object-shorthand": "warn", | ||
"prettier/prettier": "warn" | ||
} | ||
} |
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,4 @@ | ||
{ | ||
"printWidth": 80, | ||
"singleQuote": true | ||
} |
Empty file.
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,61 @@ | ||
{ | ||
"name": "@linode/ui", | ||
"author": "Linode", | ||
"description": "Linode UI component library", | ||
"version": "0.0.1", | ||
"type": "module", | ||
"main": "src/index.ts", | ||
"module": "src/index.ts", | ||
"types": "src/index.ts", | ||
"exports": { | ||
".": "./src/index.ts" | ||
}, | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/linode/manager/tree/develop/packages/ui" | ||
}, | ||
"dependencies": { | ||
"@emotion/react": "^11.11.1", | ||
"@emotion/styled": "^11.11.0", | ||
"@mui/material": "^5.14.7", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"scripts": { | ||
"start": "tsc -w --preserveWatchOutput", | ||
"lint": "eslint . --quiet --ext .js,.ts,.tsx", | ||
"typecheck": "tsc", | ||
"precommit": "lint-staged", | ||
"test": "vitest run", | ||
"test:watch": "vitest", | ||
"test:debug": "node --inspect-brk scripts/test.js --runInBand", | ||
"coverage": "vitest run --coverage && open coverage/index.html", | ||
"coverage:summary": "vitest run --coverage.enabled --reporter=junit --coverage.reporter=json-summary" | ||
}, | ||
"lint-staged": { | ||
"*.{ts,tsx,js}": [ | ||
"prettier --write", | ||
"eslint --ext .js,.ts,.tsx --quiet" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@linode/eslint-plugin-cloud-manager": "^0.0.5", | ||
"@testing-library/dom": "^10.1.0", | ||
"@testing-library/jest-dom": "~6.4.2", | ||
"@testing-library/react": "~16.0.0", | ||
"@types/node": "^12.7.1", | ||
"@types/react": "^18.2.55", | ||
"@types/react-dom": "^18.2.18", | ||
"@typescript-eslint/eslint-plugin": "^6.21.0", | ||
"@typescript-eslint/parser": "^6.21.0", | ||
"@vitest/ui": "^2.1.1", | ||
"eslint": "^7.1.0", | ||
"eslint-config-prettier": "~8.1.0", | ||
"eslint-plugin-prettier": "~3.3.1", | ||
"eslint-plugin-sonarjs": "^0.5.0", | ||
"lint-staged": "^15.2.9", | ||
"prettier": "~2.2.1", | ||
"vitest": "^2.1.1" | ||
} | ||
} |
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,33 @@ | ||
import { fireEvent, render } from '@testing-library/react'; | ||
import React from 'react'; | ||
|
||
import { BetaChip } from './BetaChip'; | ||
|
||
import { expect, vi, describe, it } from 'vitest'; | ||
import '@testing-library/jest-dom/vitest'; | ||
|
||
describe('BetaChip', () => { | ||
it('renders with default color', () => { | ||
const { getByTestId } = render(<BetaChip />); | ||
const betaChip = getByTestId('betaChip'); | ||
expect(betaChip).toBeInTheDocument(); | ||
expect(betaChip).toHaveStyle('background-color: rgba(0, 0, 0, 0.08)'); | ||
}); | ||
|
||
it('renders with primary color', () => { | ||
const { getByTestId } = render(<BetaChip color="primary" />); | ||
const betaChip = getByTestId('betaChip'); | ||
expect(betaChip).toBeInTheDocument(); | ||
expect(betaChip).toHaveStyle('background-color: rgb(25, 118, 210)'); | ||
}); | ||
|
||
it('triggers an onClick callback', () => { | ||
const onClickMock = vi.fn(); | ||
const { getByTestId } = render( | ||
<BetaChip color="default" onClick={onClickMock} /> | ||
); | ||
const betaChip = getByTestId('betaChip'); | ||
fireEvent.click(betaChip); | ||
expect(onClickMock).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
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,62 @@ | ||
import { styled } from '@mui/material/styles'; | ||
import * as React from 'react'; | ||
import { Chip } from '../Chip'; | ||
import type { ChipProps } from '@mui/material'; | ||
|
||
export interface BetaChipProps | ||
extends Omit< | ||
ChipProps, | ||
| 'avatar' | ||
| 'clickable' | ||
| 'deleteIcon' | ||
| 'disabled' | ||
| 'icon' | ||
| 'label' | ||
| 'onDelete' | ||
| 'outlineColor' | ||
| 'size' | ||
| 'variant' | ||
> { | ||
/** | ||
* The color of the chip. | ||
* default renders a gray chip, primary renders a blue chip. | ||
*/ | ||
color?: 'default' | 'primary'; | ||
} | ||
|
||
/** | ||
* ## Usage | ||
* | ||
* Beta chips label features that are not yet part of Cloud Manager's core supported functionality.<br> | ||
* **Example:** A beta chip may appear in the [primary navigation](https://github.com/linode/manager/pull/8104#issuecomment-1309334374), | ||
* breadcrumbs, [banners](/docs/components-notifications-dismissible-banners--beta-banners), tabs, and/or plain text to designate beta functionality.<br> | ||
* **Visual style:** bold, capitalized text; reduced height, letter spacing, and font size; solid color background. | ||
* | ||
*/ | ||
export const BetaChip = (props: BetaChipProps) => { | ||
const { color } = props; | ||
|
||
return ( | ||
<StyledBetaChip | ||
{...props} | ||
color={color} | ||
data-testid="betaChip" | ||
label="beta" | ||
/> | ||
); | ||
}; | ||
|
||
const StyledBetaChip = styled(Chip, { | ||
label: 'StyledBetaChip', | ||
})<BetaChipProps>(({ theme }) => ({ | ||
'& .MuiChip-label': { | ||
padding: 0, | ||
}, | ||
fontSize: '0.625rem', | ||
fontFamily: '"LatoWebBold", sans-serif', // TODO: remove hardcoded font once theme is added to this package | ||
height: 16, | ||
letterSpacing: '.25px', | ||
marginLeft: theme.spacing(0.5), | ||
padding: theme.spacing(0.5), | ||
textTransform: 'uppercase', | ||
})); |
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 @@ | ||
export * from './BetaChip'; |
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,8 @@ | ||
import { default as _Chip } from '@mui/material/Chip'; | ||
import * as React from 'react'; | ||
|
||
import type { ChipProps } from '@mui/material/Chip'; | ||
|
||
export const Chip = (props: ChipProps) => { | ||
return <_Chip {...props} />; | ||
}; |
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,2 @@ | ||
export * from './Chip'; | ||
export * from './BetaChip'; |
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 @@ | ||
export * from './components'; |
Oops, something went wrong.