-
Notifications
You must be signed in to change notification settings - Fork 364
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
upcoming: [M3-8638] - Introduce the new (at)linode/ui
package
#11057
Changes from 3 commits
d381228
ffdafaf
df0f1cd
ea34d27
b525315
f498604
07e4450
7385010
f805147
45078a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
hkhalil-akamai marked this conversation as resolved.
Show resolved
Hide resolved
|
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. |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copied from |
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" | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copied from |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"printWidth": 80, | ||
"singleQuote": true | ||
} |
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 --noEmit true --emitDeclarationOnly false", | ||
hkhalil-akamai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"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.5.0", | ||
"@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" | ||
} | ||
} |
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', () => { | ||
hkhalil-akamai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { styled } from '@mui/material/styles'; | ||
import * as React from 'react'; | ||
import { Chip, ChipProps } from '../Chip'; | ||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
height: 16, | ||
letterSpacing: '.25px', | ||
marginLeft: theme.spacing(0.5), | ||
padding: theme.spacing(0.5), | ||
textTransform: 'uppercase', | ||
})); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './BetaChip'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a job that typechecks the new UI package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added. Side note: why don't we typecheck the api-v4 and validation packages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build steps for api-v4 and validation (
build-validation
,build-sdk
) inherently type-check because they runtsc
during the build process