Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/github_actions/actions/checkout-4
Browse files Browse the repository at this point in the history
  • Loading branch information
tosaken1116 authored Nov 7, 2023
2 parents cd9759e + 9f8d755 commit becdec5
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 7 deletions.
13 changes: 12 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,18 @@
"html": true
}
],

// Reactの明示的なimportを禁止する
"no-restricted-imports": [
"error",
{
"paths": [
{
"name": "react",
"importNames": ["default"]
}
]
}
],
// 型の名前をパスカルケースにする
"@typescript-eslint/naming-convention": [
"error",
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/auto_merge.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Dependabot auto-merge
on: pull_request

on:
pull_request_target:
types:
- opened
permissions:
contents: write
pull-requests: write
Expand All @@ -15,9 +17,16 @@ jobs:
uses: dependabot/fetch-metadata@v1
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
- name: Enable auto-merge for Dependabot PRs

- name: approve
if: contains(steps.metadata.outputs.dependency-names, 'my-dependency') && steps.metadata.outputs.update-type == 'version-update:semver-patch'

run: gh pr review --approve "$PR_URL"

- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL"

env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
6 changes: 4 additions & 2 deletions .github/workflows/chromatic_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name: 'Chromatic'

on: push
on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
chromatic-deployment:
runs-on: ubuntu-latest
if: !contains(github.event.head_commit.message , 'dependabot')
if: github.event.pull_request.user.login != 'dependabot[bot]'
steps:
- uses: actions/checkout@v4
- name: Install dependencies
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@commitlint/config-conventional": "^17.7.0",
"@markuplint/jsx-parser": "^3.11.0",
"@markuplint/react-spec": "^3.12.0",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-slot": "^1.0.2",
"@stoplight/prism-cli": "^5.4.0",
"@storybook/addon-essentials": "^7.5.1",
Expand Down
27 changes: 27 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions src/components/ui/Avatar/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Avatar, AvatarFallback, AvatarImage } from '.';

import type { Meta, StoryObj } from '@storybook/react';

const meta: Meta<typeof Avatar> = {
component: Avatar,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
};

export default meta;

type Story = StoryObj<typeof Avatar>;

export const Default: Story = {
render: () => (
<Avatar>
<AvatarImage src="https://github.com/shadcn.png" />
<AvatarFallback>CN</AvatarFallback>
</Avatar>
),
};

export const Fallback: Story = {
render: () => (
<Avatar>
<AvatarFallback>CN</AvatarFallback>
</Avatar>
)
}
35 changes: 35 additions & 0 deletions src/components/ui/Avatar/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { render, screen } from '@testing-library/react';

import '@testing-library/jest-dom';

import { Avatar, AvatarFallback, AvatarImage } from '.';

describe('test ui/Avatar', () => {
it('renders Avatar correctly', () => {
const { container } = render(<Avatar />);
expect(container.firstChild).toHaveClass(
'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full'
);
});

it('renders Avatar with AvatarImage, AvatarFallback correctly', () => {
const fallbackText = 'FB';
const imageUrl = 'https://github.com/shadcn.png'
render(
<Avatar>
<AvatarImage src={imageUrl} />
<AvatarFallback>{fallbackText}</AvatarFallback>
</Avatar>
);

const fallback = screen.getByText(fallbackText);
expect(fallback).toBeInTheDocument();
expect(fallback).toHaveClass(
'flex h-full w-full items-center justify-center rounded-full bg-muted'
);

expect(fallback.parentElement).toHaveClass(
'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full'
);
});
});
51 changes: 51 additions & 0 deletions src/components/ui/Avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use client';

import { forwardRef } from 'react';

import * as AvatarPrimitive from '@radix-ui/react-avatar';

import { cn } from '@/libs/utils';

const Avatar = forwardRef<
React.ElementRef<typeof AvatarPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Root
ref={ref}
className={cn(
'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full',
className
)}
{...props}
/>
));
Avatar.displayName = AvatarPrimitive.Root.displayName;

const AvatarImage = forwardRef<
React.ElementRef<typeof AvatarPrimitive.Image>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Image
ref={ref}
className={cn('aspect-square h-full w-full', className)}
{...props}
/>
));
AvatarImage.displayName = AvatarPrimitive.Image.displayName;

const AvatarFallback = forwardRef<
React.ElementRef<typeof AvatarPrimitive.Fallback>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Fallback
ref={ref}
className={cn(
'flex h-full w-full items-center justify-center rounded-full bg-muted',
className
)}
{...props}
/>
));
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;

export { Avatar, AvatarImage, AvatarFallback };
1 change: 0 additions & 1 deletion src/components/ui/Tag/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { FC, HTMLAttributes, ReactNode } from 'react';
import React from 'react';

import { cva, type VariantProps } from 'class-variance-authority';
import Link from 'next/link';
Expand Down

0 comments on commit becdec5

Please sign in to comment.