-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(component): add button group component (#167)
* refactor: update the pseudo element content setting * feat(component): add button group component * chore: add example for button group * docs: update button group doc
- Loading branch information
1 parent
5d15696
commit ecd9e00
Showing
19 changed files
with
264 additions
and
23 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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<template> | ||
<div space-y-2> | ||
<div fscw gap-2> | ||
<o-button-group> | ||
<o-button type="primary"> | ||
Previous Page | ||
<template #icon> | ||
<div i-carbon-chevron-left /> | ||
</template> | ||
</o-button> | ||
<o-button type="secondary" class="align-bottom"> | ||
Next Page <div i-carbon-chevron-right /> | ||
</o-button> | ||
</o-button-group> | ||
<o-button-group> | ||
<OButton> | ||
<template #icon> | ||
<div i-carbon-asleep /> | ||
</template> | ||
</OButton> | ||
<OButton> | ||
<template #icon> | ||
<div i-carbon-basketball /> | ||
</template> | ||
</OButton> | ||
<OButton> | ||
<template #icon> | ||
<div i-carbon-ai-status-rejected /> | ||
</template> | ||
</OButton> | ||
</o-button-group> | ||
<o-button-group spacer> | ||
<OButton rounded-full type="primary"> | ||
<template #icon> | ||
<div i-carbon-asleep /> | ||
</template> | ||
</OButton> | ||
<OButton rounded-full type="primary"> | ||
<template #icon> | ||
<div i-carbon-basketball /> | ||
</template> | ||
</OButton> | ||
<OButton rounded-full type="primary"> | ||
<template #icon> | ||
<div i-carbon-ai-status-rejected /> | ||
</template> | ||
</OButton> | ||
</o-button-group> | ||
</div> | ||
</div> | ||
</template> |
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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { withInstall } from '@onu-ui/utils' | ||
import ButtonGroup from '../button/src/button-group.vue' | ||
|
||
export const OButtonGroup = withInstall(ButtonGroup) | ||
export default OButtonGroup | ||
|
||
export * from '../button/src/button-group' |
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,7 +1,8 @@ | ||
import { withInstall } from '@onu-ui/utils' | ||
import Button from './src/index.vue' | ||
import Button from './src/button.vue' | ||
|
||
export const OButton = withInstall(Button) | ||
export default OButton | ||
|
||
export * from './src/props' | ||
export * from './src/button' | ||
export * from './src/constants' |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { ExtractPropTypes } from 'vue' | ||
import { buttonProps } from './button' | ||
|
||
export const buttonGroupProps = { | ||
type: buttonProps.type, | ||
size: buttonProps.size, | ||
spacer: Boolean, | ||
} | ||
|
||
export type OButtonGroupProps = ExtractPropTypes<typeof buttonGroupProps> |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<script setup lang="ts" name="OButtonGroup"> | ||
import { buttonGroupProps } from './button-group' | ||
import { buttonGroupContextKey } from './constants' | ||
const props = defineProps(buttonGroupProps) | ||
provide( | ||
buttonGroupContextKey, | ||
reactive({ | ||
size: toRef(props, 'size'), | ||
type: toRef(props, 'type'), | ||
}), | ||
) | ||
</script> | ||
|
||
<template> | ||
<div class="o-button-group o-button-group-clearfix inline-block align-middle o-button-group-children" :class="[spacer && 'spacer']"> | ||
<slot /> | ||
</div> | ||
</template> | ||
|
||
<style scope> | ||
.o-button-group > .o-button-base + .o-button-base { | ||
margin-left: 0; | ||
} | ||
.o-button-group > .o-button-base:first-child:not(:last-child) { | ||
border-top-right-radius: 0; | ||
border-bottom-right-radius: 0; | ||
} | ||
.o-button-group > .o-button-base:last-child:not(:first-child) { | ||
border-top-left-radius: 0; | ||
border-bottom-left-radius: 0; | ||
} | ||
.o-button-group > .o-button-base:not(:first-child):not(:last-child) { | ||
border-radius: 0; | ||
} | ||
.o-button-group > .o-button-base:not(:last-child) { | ||
/* margin-right: -1px; */ | ||
border-right: none; | ||
} | ||
.o-button-group.spacer > .o-button-base:not(:first-child) { | ||
border-left-color: white; | ||
} | ||
.o-button-group > .o-button-base:hover, .o-button-group > .o-button-base:focus, .o-button-group > .o-button-base:active { | ||
z-index: 1; | ||
} | ||
</style> |
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
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { InjectionKey } from 'vue' | ||
import type { OButtonProps } from './button' | ||
|
||
export interface OButtonGroupContext { | ||
size?: OButtonProps['size'] | ||
type?: OButtonProps['type'] | ||
} | ||
|
||
export const buttonGroupContextKey: InjectionKey<OButtonGroupContext> = Symbol( | ||
'buttonGroupContextKey', | ||
) |
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const buttonGroupShortcuts: Record<string, string> = { | ||
// button group | ||
'o-button-group-clearfix': 'o-after:psdc-DEFAULT after:clear-both after:table o-before:psdc-DEFAULT before:table', | ||
'o-button-group-children': 'o-children:[.o-button-base]:left o-children:[.o-button-base]:relative', | ||
} |
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
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
Oops, something went wrong.