-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bacd787
commit a937ac3
Showing
41 changed files
with
3,726 additions
and
3,546 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,60 @@ | ||
import { Container, Graphics, Text } from "pixi.js"; | ||
import { PixiStory, StoryFn } from "@pixi/storybook-renderer"; | ||
import { ButtonContainer } from "../../Button"; | ||
import { centerElement } from "../../utils/helpers/resize"; | ||
import { argTypes, getDefaultArgs } from "../utils/argTypes"; | ||
import { action } from "@storybook/addon-actions"; | ||
import { Container, Graphics, Text } from 'pixi.js'; | ||
import { PixiStory, StoryFn } from '@pixi/storybook-renderer'; | ||
import { ButtonContainer } from '../../Button'; | ||
import { centerElement } from '../../utils/helpers/resize'; | ||
import { argTypes, getDefaultArgs } from '../utils/argTypes'; | ||
import { action } from '@storybook/addon-actions'; | ||
|
||
const args = { | ||
color: "#A5E24D", | ||
size: 150, | ||
radius: 150, | ||
disabled: false, | ||
action: action("Button"), | ||
color: '#A5E24D', | ||
size: 150, | ||
radius: 150, | ||
disabled: false, | ||
action: action('Button'), | ||
}; | ||
|
||
export const ButtonContainerSprite: StoryFn<typeof args> = ( | ||
{ size, color, disabled, radius, action }, | ||
context, | ||
) => | ||
new PixiStory<typeof args>({ | ||
{ size, color, disabled, radius, action }, | ||
context, | ||
init(view) { | ||
// Component usage !!! | ||
const button = new ButtonContainer(); | ||
|
||
button.enabled = !disabled; | ||
|
||
button.onPress.connect(() => action("onPress")); | ||
button.onDown.connect(() => action("onDown")); | ||
button.onUp.connect(() => action("onUp")); | ||
button.onHover.connect(() => action("onHover")); | ||
button.onOut.connect(() => action("onOut")); | ||
button.onUpOut.connect(() => action("onUpOut")); | ||
|
||
const buttonView = new Container(); | ||
const buttonBg = new Graphics() | ||
.roundRect(0, 0, size, size, radius) | ||
.fill(color); | ||
const text = new Text({ text: "🤙", style: { fontSize: 70 } }); | ||
|
||
text.anchor.set(0.5); | ||
text.x = buttonBg.width / 2; | ||
text.y = buttonBg.height / 2; | ||
|
||
buttonView.addChild(buttonBg, text); | ||
|
||
button.addChild(buttonView); | ||
view.addChild(button); | ||
|
||
centerElement(button); | ||
}, | ||
resize: (view) => centerElement(view.children[0]), | ||
}); | ||
) => | ||
new PixiStory<typeof args>({ | ||
context, | ||
init(view) | ||
{ | ||
// Component usage !!! | ||
const button = new ButtonContainer(); | ||
|
||
button.enabled = !disabled; | ||
|
||
button.onPress.connect(() => action('onPress')); | ||
button.onDown.connect(() => action('onDown')); | ||
button.onUp.connect(() => action('onUp')); | ||
button.onHover.connect(() => action('onHover')); | ||
button.onOut.connect(() => action('onOut')); | ||
button.onUpOut.connect(() => action('onUpOut')); | ||
|
||
const buttonView = new Container(); | ||
const buttonBg = new Graphics() | ||
.roundRect(0, 0, size, size, radius) | ||
.fill(color); | ||
const text = new Text({ text: '🤙', style: { fontSize: 70 } }); | ||
|
||
text.anchor.set(0.5); | ||
text.x = buttonBg.width / 2; | ||
text.y = buttonBg.height / 2; | ||
|
||
buttonView.addChild(buttonBg, text); | ||
|
||
button.addChild(buttonView); | ||
view.addChild(button); | ||
|
||
centerElement(button); | ||
}, | ||
resize: (view) => centerElement(view.children[0]), | ||
}); | ||
|
||
export default { | ||
title: "Components/Button/Button Container Sprite", | ||
argTypes: argTypes(args), | ||
args: getDefaultArgs(args), | ||
title: 'Components/Button/Button Container Sprite', | ||
argTypes: argTypes(args), | ||
args: getDefaultArgs(args), | ||
}; |
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 |
---|---|---|
@@ -1,57 +1,58 @@ | ||
import { Container, Graphics, Text } from "pixi.js"; | ||
import { PixiStory, StoryFn } from "@pixi/storybook-renderer"; | ||
import { Button } from "../../Button"; | ||
import { centerElement } from "../../utils/helpers/resize"; | ||
import { argTypes, getDefaultArgs } from "../utils/argTypes"; | ||
import { action } from "@storybook/addon-actions"; | ||
import { Container, Graphics, Text } from 'pixi.js'; | ||
import { PixiStory, StoryFn } from '@pixi/storybook-renderer'; | ||
import { Button } from '../../Button'; | ||
import { centerElement } from '../../utils/helpers/resize'; | ||
import { argTypes, getDefaultArgs } from '../utils/argTypes'; | ||
import { action } from '@storybook/addon-actions'; | ||
|
||
const args = { | ||
color: "#A5E24D", | ||
size: 150, | ||
radius: 150, | ||
disabled: false, | ||
action: action("Button"), | ||
color: '#A5E24D', | ||
size: 150, | ||
radius: 150, | ||
disabled: false, | ||
action: action('Button'), | ||
}; | ||
|
||
export const UseGraphics: StoryFn<typeof args> = ( | ||
{ size, color, disabled, radius, action }, | ||
context, | ||
) => | ||
new PixiStory<typeof args>({ | ||
{ size, color, disabled, radius, action }, | ||
context, | ||
init: (view) => { | ||
const buttonView = new Container(); | ||
const buttonBg = new Graphics() | ||
.roundRect(0, 0, size, size, radius) | ||
.fill(color); | ||
const text = new Text({ text: "🤙", style: { fontSize: 70 } }); | ||
|
||
text.anchor.set(0.5); | ||
text.x = buttonBg.width / 2; | ||
text.y = buttonBg.height / 2; | ||
|
||
buttonView.addChild(buttonBg, text); | ||
|
||
// Component usage !!! | ||
const button = new Button(buttonView); | ||
|
||
button.enabled = !disabled; | ||
|
||
button.onPress.connect(() => action("onPress")); | ||
button.onDown.connect(() => action("onDown")); | ||
button.onUp.connect(() => action("onUp")); | ||
button.onHover.connect(() => action("onHover")); | ||
button.onOut.connect(() => action("onOut")); | ||
button.onUpOut.connect(() => action("onUpOut")); | ||
view.addChild(buttonView); | ||
|
||
centerElement(buttonView); | ||
}, | ||
resize: (view) => centerElement(view.children[0]), | ||
}); | ||
) => | ||
new PixiStory<typeof args>({ | ||
context, | ||
init: (view) => | ||
{ | ||
const buttonView = new Container(); | ||
const buttonBg = new Graphics() | ||
.roundRect(0, 0, size, size, radius) | ||
.fill(color); | ||
const text = new Text({ text: '🤙', style: { fontSize: 70 } }); | ||
|
||
text.anchor.set(0.5); | ||
text.x = buttonBg.width / 2; | ||
text.y = buttonBg.height / 2; | ||
|
||
buttonView.addChild(buttonBg, text); | ||
|
||
// Component usage !!! | ||
const button = new Button(buttonView); | ||
|
||
button.enabled = !disabled; | ||
|
||
button.onPress.connect(() => action('onPress')); | ||
button.onDown.connect(() => action('onDown')); | ||
button.onUp.connect(() => action('onUp')); | ||
button.onHover.connect(() => action('onHover')); | ||
button.onOut.connect(() => action('onOut')); | ||
button.onUpOut.connect(() => action('onUpOut')); | ||
view.addChild(buttonView); | ||
|
||
centerElement(buttonView); | ||
}, | ||
resize: (view) => centerElement(view.children[0]), | ||
}); | ||
|
||
export default { | ||
title: "Components/Button/Use Graphics", | ||
argTypes: argTypes(args), | ||
args: getDefaultArgs(args), | ||
title: 'Components/Button/Use Graphics', | ||
argTypes: argTypes(args), | ||
args: getDefaultArgs(args), | ||
}; |
Oops, something went wrong.