You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+32-14Lines changed: 32 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -97,25 +97,43 @@ git cz
97
97
98
98
> Rules below apply to adapter component source code. For demo site code, follow [vuejs-component-style-guide](https://pablohpsilva.github.io/vuejs-component-style-guide/#/).
99
99
100
-
- Adapter plugin shall be located @ `components/[feature]/`
101
-
where _feature_ matches the pkg name of the component being wrapped: `@material/[feature]`
100
+
The style guide is organized into two types of rules: enforced and recommended.
102
101
103
-
- Each feature `components/[feature]` package shall be a vue plugin and export the components as well.
102
+
Enforced rules are designed to reduce bugs and must be followed. Code that does not conform to enforced rules may be rejected.
104
103
105
-
- Component shall have a name property which matches the MDC component css class name, kebab case. for example: _mdc_button.vue_ adapts `<button class="mdc-button"> ... </button>`
104
+
Recommended rules should be followed to maintain a consistent and readable codebase but failure to do so is not grounds for rejection of a pull request.
106
105
107
-
- Adapter plugins shall register the vue components with the same element name as the component name property.
106
+
## Enforced Rules
108
107
109
-
- Single File Components shall have a `<template>` and `<script>` section, with no lang specified (this is to avoid vue support issues with the complex build env.)
108
+
All of Vue's official style guide [prority A rules](https://vuejs.org/v2/style-guide/#Priority-A-Rules-Essential-Error-Prevention) are enforced with the exception of [scoped styles](https://vuejs.org/v2/style-guide/#Component-style-scoping-essential). Due to the way that MDC works, some global styles are required.
110
109
111
-
- styles shall not be put in the `.vue` sfc file. styles shall be kept in a separate sass file.
110
+
### Single-File Components
112
111
113
-
- vue component should have a class on the main mdc element which matches the component name (this is to allow customization).
112
+
- SFC sections should be only `<template>` and `<script>` with no attributes
113
+
- SFC should not have a `<style>` section. (build env requirement to avoid issues with sass: stylesheet goes to style.scss)
114
+
- SFC template section has no attributes (=> html).
115
+
- SFC script section has no attributes (=> es6)
114
116
115
-
- when adapting an mdc component do not wrap the mdc component, implement the mdc foundation.
117
+
### Distributed Plugins
116
118
117
-
- when importing foundation from @material/xxx, import from the foundation module instead of pullingthe full package
118
-
__don't__
119
-
~~`import { MDCCheckboxFoundation } from '@material/checkbox'`~~
120
-
do
121
-
`import MDCCheckboxFoundation from '@material/checkbox/foundation'`
119
+
- A distributed package's default export should be a valid Vue plugin (expose an [install function](https://vuejs.org/v2/guide/plugins.html#Writing-a-Plugin)) *OR* a Vue mixin
120
+
- The source code for plugins should be located in `components/[plugin]/*`
121
+
- Adapter plugins shall register the vue components with the same element name as the component name property.
122
+
123
+
### Distributed Components
124
+
125
+
- Component source code should be located in `components/[plugin]/mdc-xxx-yyy.(vue|js)`
126
+
- The name of the component should be prefixed with `mdc-`
127
+
- Has a static class which exactly matches the component name
128
+
-`data` must be a function
129
+
-`provide` must be a function
130
+
- MDC adapters must **exactly** match the MDC API
131
+
- When adapting an MDC component do not wrap the MDC component, implement the MDC foundation.
132
+
133
+
### Miscellaneous
134
+
135
+
- When importing foundation from @material/xxx, import from the foundation module instead of pulling the entire package
136
+
__don't__
137
+
~~`import { MDCCheckboxFoundation } from '@material/checkbox'`~~
138
+
do
139
+
`import MDCCheckboxFoundation from '@material/checkbox/foundation'`
0 commit comments