Skip to content

Commit

Permalink
Refactor #3965 - For Toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed May 19, 2023
1 parent 3ce238b commit a21c83e
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 34 deletions.
57 changes: 57 additions & 0 deletions components/lib/toolbar/BaseToolbar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<script>
import BaseComponent from 'primevue/basecomponent';
import { useStyle } from 'primevue/usestyle';
const styles = `
.p-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
}
.p-toolbar-group-start,
.p-toolbar-group-center,
.p-toolbar-group-end {
display: flex;
align-items: center;
}
.p-toolbar-group-left,
.p-toolbar-group-right {
display: flex;
align-items: center;
}
`;
const classes = {
root: 'p-toolbar p-component',
start: 'p-toolbar-group-start p-toolbar-group-left',
center: 'p-toolbar-group-center',
end: 'p-toolbar-group-end p-toolbar-group-right'
};
const { load: loadStyle, unload: unloadStyle } = useStyle(styles, { id: 'primevue_toolbar_style', manual: true });
export default {
name: 'BaseToolbar',
extends: BaseComponent,
props: {
'aria-labelledby': {
type: String,
default: null
}
},
css: {
classes
},
watch: {
isUnstyled: {
immediate: true,
handler(newValue) {
!newValue && loadStyle();
}
}
}
};
</script>
5 changes: 5 additions & 0 deletions components/lib/toolbar/Toolbar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ export interface ToolbarProps {
* @type {ToolbarPassThroughOptions}
*/
pt?: ToolbarPassThroughOptions;
/**
* When enabled, it removes component related styles in the core.
* @defaultValue false
*/
unstyled?: boolean;
}

/**
Expand Down
41 changes: 7 additions & 34 deletions components/lib/toolbar/Toolbar.vue
Original file line number Diff line number Diff line change
@@ -1,49 +1,22 @@
<template>
<div class="p-toolbar p-component" role="toolbar" :aria-labelledby="ariaLabelledby" v-bind="ptm('root')">
<div class="p-toolbar-group-start p-toolbar-group-left" v-bind="ptm('start')">
<div :class="cx('root')" role="toolbar" :aria-labelledby="ariaLabelledby" data-pc-name="toolbar" data-pc-section="root" v-bind="ptm('root')">
<div :class="cx('start')" data-pc-section="start" v-bind="ptm('start')">
<slot name="start"></slot>
</div>
<div class="p-toolbar-group-center" v-bind="ptm('center')">
<div :class="cx('center')" data-pc-section="center" v-bind="ptm('center')">
<slot name="center"></slot>
</div>
<div class="p-toolbar-group-end p-toolbar-group-right" v-bind="ptm('end')">
<div :class="cx('end')" data-pc-section="end" v-bind="ptm('end')">
<slot name="end"></slot>
</div>
</div>
</template>

<script>
import BaseComponent from 'primevue/basecomponent';
import BaseToolbar from './BaseToolbar.vue';
export default {
name: 'Toolbar',
extends: BaseComponent,
props: {
'aria-labelledby': {
type: String,
default: null
}
}
extends: BaseToolbar
};
</script>

<style>
.p-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
}
.p-toolbar-group-start,
.p-toolbar-group-center,
.p-toolbar-group-end {
display: flex;
align-items: center;
}
.p-toolbar-group-left,
.p-toolbar-group-right {
display: flex;
align-items: center;
}
</style>

0 comments on commit a21c83e

Please sign in to comment.