Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions packages/components-web/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@
@forward "@pepabo-inhouse/table" as table-*;
@forward "@pepabo-inhouse/textfield" as textfield-*;
@forward "@pepabo-inhouse/snackbar" as snackbar-*;
@forward "@pepabo-inhouse/sticker" as sticker-*;
@forward "@pepabo-inhouse/validation-message" as validation-message-*;
2 changes: 2 additions & 0 deletions packages/components-web/inhouse-components-web.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
@use "@pepabo-inhouse/table";
@use "@pepabo-inhouse/textfield";
@use "@pepabo-inhouse/snackbar";
@use "@pepabo-inhouse/sticker";
@use "@pepabo-inhouse/validation-message";

// flavor内で@import が存在しているので最初に flavor を読む
Expand Down Expand Up @@ -62,4 +63,5 @@
@include table.export;
@include textfield.export;
@include snackbar.export;
@include sticker.export;
@include validation-message.export;
1 change: 1 addition & 0 deletions packages/components-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@pepabo-inhouse/side-navigation": "^4.0.0",
"@pepabo-inhouse/skeleton": "^4.0.0",
"@pepabo-inhouse/snackbar": "^4.0.0",
"@pepabo-inhouse/sticker": "^4.0.0",
"@pepabo-inhouse/tab": "^4.0.0",
"@pepabo-inhouse/table": "^4.0.0",
"@pepabo-inhouse/textfield": "^4.0.0",
Expand Down
13 changes: 13 additions & 0 deletions packages/sticker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Inhouse Sticker

## Usage

### Installation

```bash
$ npm install @pepabo-inhouse/sticker

# or

$ yarn add @pepabo-inhouse/sticker
```
1 change: 1 addition & 0 deletions packages/sticker/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@forward "./mixins" show style, export;
137 changes: 137 additions & 0 deletions packages/sticker/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
@use "sass:map";
@use "@pepabo-inhouse/adapter/functions" as adapter;
@use "@pepabo-inhouse/skeleton/mixins" as skeleton;
@use "./variables";

@mixin export {
.in-sticker {
@include style;
}

.in-skeleton-sticker {
@include skeleton-style;
}
}

@mixin style($options: variables.$default-option) {
$options: map.merge(variables.$default-option, $options);

@include -proto;
@include -color-style(
$color: map.get($options, color),
$appearance: map.get($options, appearance)
);
@include -size-style(
$size: map.get($options, size)
);

& > * {
@include -child-element-style;
}

@each $color in adapter.get-semantic-intentions() {
&.-color-#{$color} {
@include -color-style(
$color: $color,
$appearance: map.get($options, appearance)
);

@each $appearance in variables.$available-appearances {
&.-appearance-#{$appearance} {
@include -color-style(
$color: $color,
$appearance: $appearance
);
}
}
}
}

@each $appearance in variables.$available-appearances {
&.-appearance-#{$appearance} {
@include -color-style(
$color: map.get($options, color),
$appearance: $appearance
);
}
}

@each $size in adapter.get-interactive-component-height-keys() {
&.-size-#{$size} {
@include -size-style($size: $size);
}
}
}

@mixin skeleton-style($options: variables.$default-option) {
$options: map.merge(variables.$default-option, $options);

@include skeleton.style;

display: inline-block;
width: auto;
height:
calc(
adapter.get-line-height(
$level: map.get($options, size),
$density: normal
) + adapter.get-spacing-size($level: xs)
);
border-radius: 4px;

@each $size in adapter.get-interactive-component-height-keys() {
&.-size-#{$size} {
height:
calc(
adapter.get-line-height(
$level: $size,
$density: normal
) + adapter.get-spacing-size($level: xs)
);
}
}
}

@mixin -proto {
display: inline-flex;
gap: adapter.get-spacing-size($level: xxs);
align-items: center;
font-family: inherit;
white-space: nowrap;
}

@mixin -child-element-style {
display: inline-flex;
align-items: center;
justify-content: center;
}

@mixin -color-style($color, $appearance) {
@if $appearance == fill-only {
color: #fff;
background-color: adapter.get-semantic-color($color, 700);
} @else if $appearance == fill-with-outlined {
color: adapter.get-semantic-color($color, 800);
background-color: adapter.get-semantic-color($color, 100);
border: 1px solid adapter.get-semantic-color($color, 300);
} @else if $appearance == outlined {
color: adapter.get-semantic-color($color, 800);
background-color: #fff;
border: 1px solid adapter.get-semantic-color($color, 300);
} @else if $appearance == text-only {
color: adapter.get-semantic-color($color, 800);
background-color: transparent;
}
}

@mixin -size-style($size) {
font-size: adapter.get-font-size($level: $size);
line-height:
adapter.get-line-height(
$level: $size,
$density: normal
);
padding-block: calc(adapter.get-spacing-size($level: xs) / 2);
padding-inline: adapter.get-spacing-size($level: s);
border-radius: 4px;
}
12 changes: 12 additions & 0 deletions packages/sticker/_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$default-option: (
color: informative,
size: m,
appearance: fill-only,
);

$available-appearances: (
fill-only,
fill-with-outlined,
outlined,
text-only,
);
2 changes: 2 additions & 0 deletions packages/sticker/inhouse-sticker.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@use "./mixins";
@include mixins.export;
21 changes: 21 additions & 0 deletions packages/sticker/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@pepabo-inhouse/sticker",
"description": "Inhouse Components for the web sticker component",
"version": "4.0.0",
"repository": {
"type": "git",
"url": "https://github.com/pepabo/inhouse-components-web.git",
"directory": "packages/sticker"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pepabo-inhouse/adapter": "^4.0.0",
"@pepabo-inhouse/skeleton": "^4.0.0"
},
"devDependencies": {
"@pepabo-inhouse/flavor": "^4.0.0",
"@pepabo-inhouse/tokens": "^2.4.0"
}
}
40 changes: 40 additions & 0 deletions packages/stories-web/src/components/demo/StickerDemo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React, { FC } from 'react'
import Sticker, { Props as StickerProps } from '../sticker/Sticker'
import Icon from '../Icon'

export type Props = Pick<StickerProps, 'color' | 'size'>

const StickerDemo: FC<Props> = (props: Props) => (
<>
<Sticker {...props} appearance='fill-only' body='label' />
<Sticker {...props} appearance='fill-with-outlined' body='label' />
<Sticker {...props} appearance='outlined' body='label' />
<Sticker {...props} appearance='text-only' body='label' />
<Sticker
{...props}
appearance='fill-only'
body='label'
leading={<Icon className='_icon' icon='heart' />}
/>
<Sticker
{...props}
appearance='fill-with-outlined'
body='label'
leading={<Icon className='_icon' icon='heart' />}
/>
<Sticker
{...props}
appearance='outlined'
body='label'
leading={<Icon className='_icon' icon='heart' />}
/>
<Sticker
{...props}
appearance='text-only'
body='label'
leading={<Icon className='_icon' icon='heart' />}
/>
</>
)

export default StickerDemo
43 changes: 43 additions & 0 deletions packages/stories-web/src/components/sticker/SkeletonSticker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, { CSSProperties, FC } from 'react'
import { Size } from '../types'

type TextUnit = 'rem'
type TextLength = `${number}${TextUnit}`

export interface Props {
size?: Extract<Size, 'xs' | 's' | 'm' | 'l' | 'xl'>
width?: TextLength
}

const SkeletonSticker: FC<Props> = (props: Props) => {
const {
size,
width,
...rest
} = props

const classes = ['in-skeleton-sticker']
let style: CSSProperties = {}

if (typeof size !== 'undefined') {
classes.push(`-size-${size}`)
}

if (typeof width !== 'undefined') {
style = {
...style,
width: width,
}
}

return (
<div
className={classes.join(' ')}
style={style}
{...rest}
>
</div>
)
}

export default SkeletonSticker
Loading
Loading