Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 13, 2024
2 parents 0b8e53d + 1c2e575 commit a54522c
Show file tree
Hide file tree
Showing 15 changed files with 708 additions and 552 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ version: 2.1
executors:
node-maintenance:
docker:
- image: cimg/node:22.4.1
- image: cimg/node:22.6.0
auth:
username: smarthrinc
password: $DOCKER_HUB_ACCESS_TOKEN
node-active-lts:
docker:
- image: cimg/node:22.4.1
- image: cimg/node:22.6.0
auth:
username: smarthrinc
password: $DOCKER_HUB_ACCESS_TOKEN
node-active-lts-browsers:
docker:
- image: cimg/node:22.4.1-browsers
- image: cimg/node:22.6.0-browsers
auth:
username: smarthrinc
password: $DOCKER_HUB_ACCESS_TOKEN
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "SmartHR ui components built with React.",
"author": "SmartHR-UI Team",
"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/cli": "^19.4.0",
"@commitlint/config-conventional": "^19.2.2",
"eslint": "^8.57.0",
"eslint-config-smarthr": "^6.33.0",
Expand All @@ -13,7 +13,7 @@
"lint-staged": "^15.2.8",
"prettier": "^3.3.3",
"prettier-config-smarthr": "^1.0.0",
"prettier-plugin-tailwindcss": "^0.6.5",
"prettier-plugin-tailwindcss": "^0.6.6",
"stylelint": "^16.8.1",
"stylelint-config-prettier": "^9.0.5",
"stylelint-config-smarthr": "^3.0.1",
Expand All @@ -27,7 +27,7 @@
"commitmsg": "commitlint -e $GIT_PARAMS",
"prepare": "husky"
},
"packageManager": "pnpm@9.6.0",
"packageManager": "pnpm@9.7.0",
"pnpm": {
"overrides": {
"@babel/helper-compilation-targets": "^7.25.2",
Expand Down
42 changes: 21 additions & 21 deletions packages/smarthr-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,42 @@
"react-transition-group": "^4.4.5",
"style-loader": "^4.0.0",
"tailwind-variants": "^0.2.1",
"tailwindcss": "^3.4.7"
"tailwindcss": "^3.4.9"
},
"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.3",
"@babel/preset-react": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@storybook/addon-a11y": "^8.2.7",
"@storybook/addon-actions": "^8.2.7",
"@storybook/addon-essentials": "^8.2.7",
"@storybook/addon-interactions": "^8.2.7",
"@storybook/addon-storysource": "^8.2.7",
"@storybook/addon-a11y": "^8.2.8",
"@storybook/addon-actions": "^8.2.8",
"@storybook/addon-essentials": "^8.2.8",
"@storybook/addon-interactions": "^8.2.8",
"@storybook/addon-storysource": "^8.2.8",
"@storybook/addon-styling": "^1.3.7",
"@storybook/addon-styling-webpack": "^1.0.0",
"@storybook/addon-viewport": "^8.2.7",
"@storybook/addon-viewport": "^8.2.8",
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
"@storybook/blocks": "^8.2.7",
"@storybook/cli": "^8.2.7",
"@storybook/manager-api": "^8.2.7",
"@storybook/react": "^8.2.7",
"@storybook/react-webpack5": "^8.2.7",
"@storybook/source-loader": "^8.2.7",
"@storybook/test": "^8.2.7",
"@storybook/blocks": "^8.2.8",
"@storybook/cli": "^8.2.8",
"@storybook/manager-api": "^8.2.8",
"@storybook/react": "^8.2.8",
"@storybook/react-webpack5": "^8.2.8",
"@storybook/source-loader": "^8.2.8",
"@storybook/test": "^8.2.8",
"@storybook/test-runner": "^0.19.1",
"@storybook/theming": "^8.2.7",
"@swc/core": "^1.7.6",
"@storybook/theming": "^8.2.8",
"@swc/core": "^1.7.10",
"@swc/jest": "^0.2.36",
"@testing-library/react": "^16.0.0",
"@types/jest": "^29.5.12",
"@types/lodash.merge": "^4.6.9",
"@types/lodash.range": "^3.2.9",
"@types/node": "^20.14.14",
"@types/node": "^20.14.15",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-test-renderer": "^17.0.9",
"@types/react-transition-group": "^4.4.10",
"@types/react-transition-group": "^4.4.11",
"@types/styled-components": "^5.1.34",
"autoprefixer": "^10.4.20",
"axe-playwright": "^2.0.1",
Expand All @@ -69,8 +69,8 @@
"jest-styled-components": "^7.2.0",
"memory-fs": "^0.5.0",
"npm-run-all": "^4.1.5",
"playwright": "^1.45.3",
"postcss": "^8.4.40",
"playwright": "^1.46.0",
"postcss": "^8.4.41",
"postcss-styled-syntax": "^0.6.4",
"postcss-syntax": "^0.36.2",
"puppeteer": "^22.15.0",
Expand All @@ -81,7 +81,7 @@
"react-test-renderer": "^18.3.1",
"rimraf": "^6.0.1",
"standard-version": "^9.3.2",
"storybook": "^8.2.7",
"storybook": "^8.2.8",
"storybook-addon-pseudo-states": "^3.1.1",
"styled-components": "^5.3.11",
"testcafe": "3.6.2",
Expand Down
69 changes: 69 additions & 0 deletions packages/smarthr-ui/src/components/Button/Button.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React, { act } from 'react'
import { createRoot } from 'react-dom/client'

import { Button } from './Button'

describe('Button', () => {
let container: HTMLDivElement
beforeEach(() => {
container = document.createElement('div')
document.body.appendChild(container)
})
afterEach(() => {
document.body.removeChild(container)
})

describe('onClick', () => {
it('disabled / loading でない場合、発火する', () => {
const onClick = jest.fn()
act(() => {
createRoot(container).render(<Button onClick={onClick}>button</Button>)
})
document.querySelector('button')!.click()
expect(onClick).toHaveBeenCalled()
})

it('disabled / loading の場合、発火しない', () => {
const onClick = jest.fn()
act(() => {
createRoot(container).render(
<Button onClick={onClick} disabled>
button
</Button>,
)
})
document.querySelector('button')!.click()
expect(onClick).not.toHaveBeenCalled()
})

describe('form 要素でラップされている場合', () => {
it('disabled / loading でない場合、発火しない', () => {
const onSubmit = jest.fn()
act(() => {
createRoot(container).render(
<form onSubmit={onSubmit}>
<Button type="submit">button</Button>
</form>,
)
})
document.querySelector('button')!.click()
expect(onSubmit).toHaveBeenCalled()
})

it('disabled / loading の場合、発火しない', () => {
const onSubmit = jest.fn()
act(() => {
createRoot(container).render(
<form onSubmit={onSubmit}>
<Button type="submit" loading>
button
</Button>
</form>,
)
})
document.querySelector('button')!.click()
expect(onSubmit).not.toHaveBeenCalled()
})
})
})
})
9 changes: 8 additions & 1 deletion packages/smarthr-ui/src/components/Button/ButtonWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ export function ButtonWrapper({
aria-disabled={disabled}
className={buttonStyle}
ref={buttonRef}
onClick={disabled ? undefined : onClick}
onClick={
disabled
? (e) => {
e.preventDefault()
e.stopPropagation()
}
: onClick
}
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { FaAddressCardIcon } from '../Icon'
import { TextLink } from './TextLink'

export default {
title: 'Text(テキスト)/TextLink',
title: 'Navigation(ナビゲーション)/TextLink',
component: TextLink,
parameters: {
withTheming: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { TextLink } from './TextLink'
import { All } from './TextLink.stories'

export default {
title: 'Text(テキスト)/TextLink',
title: 'Navigation(ナビゲーション)/TextLink',
component: TextLink,
parameters: {
withTheming: true,
Expand Down
4 changes: 3 additions & 1 deletion packages/smarthr-ui/src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ export const Tooltip: FC<Props & ElementProps> = ({
portalRoot,
)}
{childrenWithProps}
<VisuallyHiddenText id={messageId}>{hiddenText}</VisuallyHiddenText>
<VisuallyHiddenText id={messageId} aria-hidden={!isVisible}>
{hiddenText}
</VisuallyHiddenText>
</span>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, { useCallback } from 'react'

import { Fieldset } from '../Fieldset'
import { PageHeading } from '../Heading'
import { Cluster, Stack } from '../Layout'
import { RadioButton } from '../RadioButton'

import { UpwardLink } from './UpwardLink'

import type { StoryFn, StoryObj } from '@storybook/react/*'

export default {
title: 'Navigation(ナビゲーション)/TextLink',
component: UpwardLink,
}

const Template: StoryFn = (args) => <UpwardLink {...args} href="/" />

export const Default: StoryObj = {
name: 'UpwardLink',
render: () => {
const [indent, setIndent] = React.useState(true)
const handleChange = useCallback(() => setIndent(!indent), [indent])
return (
<Stack>
<Fieldset title="インデント">
<Cluster gap={1}>
<RadioButton name="indent" onChange={handleChange} checked={indent}>
あり
</RadioButton>
<RadioButton name="indent" onChange={handleChange} checked={!indent}>
なし
</RadioButton>
</Cluster>
</Fieldset>
<Stack className="shr-bg-background shr-p-2">
<Template indent={indent}>権限一覧に戻る</Template>
<PageHeading>権限詳細</PageHeading>
</Stack>
</Stack>
)
},
}
28 changes: 28 additions & 0 deletions packages/smarthr-ui/src/components/UpwardLink/UpwardLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, { type ComponentProps } from 'react'
import { VariantProps, tv } from 'tailwind-variants'

import { FaArrowLeftIcon } from '../Icon'
import { TextLink } from '../TextLink'

const upwardLink = tv({
base: 'shr-leading-none',
variants: {
indent: {
true: '-shr-translate-x-1.25',
false: '',
},
},
})

type Props = Omit<ComponentProps<typeof TextLink>, 'prefix' | 'suffix'> &
VariantProps<typeof upwardLink>

export const UpwardLink: React.FC<Props> = ({ indent = true, className, ...rest }) => {
const style = upwardLink({ indent, className })
return (
<div className={style}>
{/* eslint-disable-next-line smarthr/a11y-anchor-has-href-attribute */}
<TextLink {...rest} prefix={<FaArrowLeftIcon />} />
</div>
)
}
1 change: 1 addition & 0 deletions packages/smarthr-ui/src/components/UpwardLink/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { UpwardLink } from './UpwardLink'
1 change: 1 addition & 0 deletions packages/smarthr-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export { Input, CurrencyInput, SearchInput } from './components/Input'
export { InputFile } from './components/InputFile'
export { Textarea } from './components/Textarea'
export { TextLink } from './components/TextLink'
export * from './components/UpwardLink'
export { Loader } from './components/Loader'
export {
ActionDialog,
Expand Down
2 changes: 2 additions & 0 deletions packages/smarthr-ui/src/smarthr-ui-preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ export default {
fontFamily: 'system-ui, sans-serif',
lineHeight: theme('lineHeight.normal'),
color: theme('colors.black'),
// Windows 環境で Yu Gothic が不用意に記号を詰めてしまうのを避ける
textSpacingTrim: 'space-all',
},
'p, dl': {
marginBlock: 'unset',
Expand Down
Loading

0 comments on commit a54522c

Please sign in to comment.