Giter VIP home page Giter VIP logo

nextcloud-libraries / nextcloud-vue Goto Github PK

View Code? Open in Web Editor NEW
210.0 16.0 81.0 126.93 MB

🍱 Vue.js components for Nextcloud app development ✌ https://npmjs.org/@nextcloud/vue

Home Page: https://nextcloud-vue-components.netlify.app/

License: GNU Affero General Public License v3.0

Makefile 0.05% Vue 67.15% JavaScript 21.04% CSS 0.39% SCSS 2.41% Python 1.66% TypeScript 7.28% HTML 0.03%
nextcloud nextcloud-design vuejs-components vuejs vuejs2 vue-components hacktoberfest

nextcloud-vue's Introduction

Vue components

npm last version Dependabot status

This repo contains the various Vue.js components that Nextcloud uses for its internal design and structure. It provides standardized UI elements for building Nextcloud app frontends with Vue.js.

Documentation

A list of available components with examples to try out is available in the documentation.

The documentation is built from the latest development branch, for stable releases the documentation can be found matching the latest minor version:

Getting started

App example

If you want to check a real live example of a nextcloud app that uses this library, you can head over to https://github.com/skjnldsv/vueexample/ We will try to maintain this repository the best we can, but some example might be obsolete. Always check this repository documentation.

Install the library

npm i --save @nextcloud/vue

Usage

To use a component, just import it:

import { NcAppNavigation, NcActions, NcActionButton } from '@nextcloud/vue'

Registering all components.

Be careful, this will registry all components and directives, even the ones not being used.

import Vue from 'vue'
import { NextcloudVuePlugin } from '@nextcloud/vue'

Vue.use(NextcloudVuePlugin)

Development setup

If you want to work on improving the components it’s best to run the latest code and link it to your local Nextcloud installation:

  1. Install the dependencies with npm ci
  2. Build the components every time you do changes: npm run build
    • To make development build: npm run dev
    • To watch for changes and rebuild automatically: npm run watch
    • To watch for changes and rebuild development build: npm run dev:watch
  3. Connect it to your local Nextcloud development setup:
    • In this repository do npm link
    • In the repository of an app do npm link @nextcloud/vue (you need to re-link any time you do npm ci in the app)
  4. Then build the app with: npm run build (or watch for changes with npm run watch)

Translations

This library uses translated strings. When you edit/create a translated string, you need to run npm run l10n:extract to update the source files. Our awesome translation community will then be notified and a bot will sync those changes automatically.

Nonetheless, it requires a bit of caution. When you implement a translated string, import the translate or translatePlural and add it in your methods like so:

<template>
	<element>
		{{ t('Choose') }}
	</element>
</template>

<script>
import { translate as t } from '@nextcloud/l10n'

export default {
	methods: {
		t,
	},
}
</script>

Please note that using a translated string as an attribute will NOT work. But it will work if it's within an element (like the example above)

<template>
	<element :prop="t('This will not work')" />
</template>

You will instead have to define the string in the data section and use the relevant variable reference.

<template>
	<element :prop="chooseProp" />
</template>

<script>
export default {
	data() {
		return {
			chooseProp: t('Choose'),
		},
	}
}
</script>

Styleguide

When developing new components or extending components, make sure to also have some bits of related documentation like examples, where applicable. To test components and the documentation in that context, you can run npm run styleguide to run a local server that serves the style guide with all the components.

Using vue-devtools in Firefox

If you want to use vue-devtools in Firefox, you need to:

  • Either enable the HMR Enabler app …
  • … or patch your nextcloud instance as follows:
diff --git a/lib/public/AppFramework/Http/ContentSecurityPolicy.php b/lib/public/AppFramework/Http/ContentSecurityPolicy.php
index 0e3a6a705d..416b8b0fb9 100644
--- a/lib/public/AppFramework/Http/ContentSecurityPolicy.php
+++ b/lib/public/AppFramework/Http/ContentSecurityPolicy.php
@@ -41,9 +41,9 @@ namespace OCP\AppFramework\Http;
  */
 class ContentSecurityPolicy extends EmptyContentSecurityPolicy {
        /** @var bool Whether inline JS snippets are allowed */
-       protected $inlineScriptAllowed = false;
+       protected $inlineScriptAllowed = true;
        /** @var bool Whether eval in JS scripts is allowed */
-       protected $evalScriptAllowed = false;
+       protected $evalScriptAllowed = true;
        /** @var bool Whether strict-dynamic should be set */
        protected $strictDynamicAllowed = false;
        /** @var array Domains from which scripts can get loaded */

Releasing a new version

  • Pull the latest changes from master or stableX
  • Checkout a new branch with the tag name (e.g v4.0.1): git checkout -b v<version>
  • Run npm version patch --no-git-tag-version (npm version minor --no-git-tag-version if minor). This will return a new version name, make sure it matches what you expect
  • Generate the changelog content from the release page. Create a draft release, select the previous tag, click generate then paste the content to the CHANGELOG.md file
    1. use the the version as tag AND title (e.g v4.0.1)
    2. add the changelog content as description (https://github.com/nextcloud-libraries/nextcloud-vue/releases)
  • Commit, push and create PR
  • Get your PR reviewed and merged
  • Create a milestone with the follow-up version at https://github.com/nextcloud-libraries/nextcloud-vue/milestones
  • Move all open tickets and PRs to the follow-up
  • Close the milestone of the version you release
  • Publish the previously drafted release on GitHub image

Releasing a pre-release

A pre-release can be built in the same way as described above, however it requires manual adjustments to avoid that npm ships the pre-release to all users:

  1. Retag latest to the last stable release

    npm dist-tag add @nextcloud/[email protected] latest

  2. Tag the new pre-release as next

    npm dist-tag add @nextcloud/[email protected] next

nextcloud-vue's People

Contributors

antreesy avatar carlschwan avatar christophwurst avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar georgehrke avatar github-actions[bot] avatar gretad avatar jancborchardt avatar jonathantreffler avatar jotoeri avatar juliakirschenheuter avatar julien-nc avatar juliushaertl avatar korelstar avatar marcoambrosini avatar mejo- avatar nextcloud-command avatar nickvergessen avatar pvince81 avatar pytal avatar raimund-schluessler avatar shgkme avatar skjnldsv avatar st3iny avatar susnux avatar szaimen avatar transifex-integration[bot] avatar violoncelloch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nextcloud-vue's Issues

Nextcloud Server compatibility range

Changes like #193 bring up the concern that the library might only be compatible with Nextcloud 15+. Regardless of that being the case, we have to think about compatibility ranges so that devs know which Nextcloud version they can use this library for.

vue.js?

Is this a strategic development? :)

Moment

As discussed at #9 (comment), I'd like to see a component for the moment.js integration, a.k.a. x seconds/minutes/hours ago thingy.

The existing Vue components suggested didn't work as expected, esp. in regards to l10n. Moreover, they wouldn't work with our live timestamp update magic (cc @nickvergessen). Hence, I've created my own component. This is what it looks like:

<template>
	<span class="live-relative-timestamp"
		  :data-timestamp="timestamp"
		  :title=title>{{ formatted }}</span>
</template>

<script>
	import moment from 'moment';

	if (typeof OC !== 'undefined') {
		moment.locale(OC.getLocale());
	}

	export default {
		name: "Moment",
		props: [
			'timestamp',
			'format'
		],
		computed: {
			title () {
				return moment.unix(this.timestamp / 1000).format(this.format || 'LLL');
			},
			formatted () {
				return moment.unix(this.timestamp / 1000).fromNow();
			}
		}
	}
</script>

It works well and can be easily integrated. The live updating also seems to work with this.

Caveats

  • Pulls in moment.js (obviously) but also lots of translations. Webpack combines some stuff, but it's still rather big. We basically have the same problem in server, but we'd now load the locals twice.
  • Depends on a global var. I've added a check for it's existence, though.

Ready to use?

Hi! I stumbled upon this repo when I was researching for a third-party app I might start tinkering on. Are these components ready to be used yet? Is it an ETA for when third-party devs can depend on this?

Get rid of checked-in `/dist` directory

Is there any sane reason to have this in git? IMO this is just cumbersome to keep in sync, causes impossible to resolve conflicts and makes viewing git diffs pain.

I checked a few other js libs and they all seem to exclude this. I also exclude the directory for my npm modules and they work just fine.

cc @skjnldsv @juliushaertl

Autocomplete component

I'd like to see a component similar to jQuery UI's autocomplete. Mail currently uses that for recipient autocompletion.

@nextcloud/vue would that make sense for other apps as well or is this too specific?

AppContent: "loading" in app-navigation

As far as I can see, there is no easy way to add the loading CSS class (loading animation) for the whole app-navigation when using the component AppContent.

Maybe, we should add a new parameter for passing CSS class names for app-navigation? Or is there another way to realize this with means of Vue?

Edit: same applies to template slot content.

Item children icons/bubbles and indicator when hovering

Have a look at this video:

nav

I don't know if it's the intended behavior, but for me there is happening too much showing/hiding.
I would change:

  • Keep the icons/bubbles (black bubbles in the video) when hovering an item.
  • When hovering a child item, keep the entire left side indicator (the blue bar).
    It actually only displays the one beside the child items.

I could do the changes. @skjnldsv what do you think?

Enable tree shaking

The size of the vue components bundle is pretty big already, mainly caused by those three libraries:

Library Stat size Parsed size
v-tooltip 184KB 55KB
vue-multiselect 44KB 44KB
datepicker 40KB 40KB

We should look into enabling webpack tree shaking to allow apps to just include the code that is actually used. So if an app doesn't use the multiselect or datepicker this could save us quite some KBs.

Bundle size treemap:
image

I tried to get this working a bit, but couldn't come up with something unforunately. @skjnldsv @ChristophWurst

add color indicator to avatar

as discussed with @jancborchardt and @skjnldsv

Add color indicator to avatar:
img_7478

We need four different indicators:

  • green circle (attending for Calendar, online for Talk)
  • red square (declined for Calendar, offline for Talk)
  • orange (tentative for Calendar, away for Talk)
  • grey (no invitation response for Calendar, (unknown status for Talk?))

It's important to have different shapes: green circle and red square, in order to accommodate dyschromatopsia

Datepicker fixes

  • Days of the week should have same colour as disabled days
  • More padding on the headers
  • Arrows with the same design as the original datepicker
  • OK button with better wording
  • Wrap it
  • Automatically use the provider locale from nc

Datepicker dark theme broken

The date/timepicker component does not work well with the NC dark theme. The screenshots are from the Tasks vue branch.

Datepicker:
screenshot_2018-11-25 aufgaben - nextcloud

Timepicker
screenshot_2018-11-25 aufgaben - nextcloud 1

There are these inline rules

.mx-datepicker-popup {
    position: absolute;
    margin-top: 1px;
    margin-bottom: 1px;
    border: 1px solid #d9d9d9;
    background-color: #fff;
    -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
    z-index: 1000;
}

.mx-input-append {
    position: absolute;
    top: 0;
    right: 0;
    width: 30px;
    height: 100%;
    padding: 6px;
    background-color: #fff;
    background-clip: content-box;
}

where especially the background-color: #fff; interfere a lot.
Also in this rule

.mx-calendar-icon {
    width: 100%;
    height: 100%;
    color: #555;
    stroke-width: 8px;
    stroke: currentColor;
    fill: currentColor;
}

color should rather be var(--color-main-text).

[0.1.1] Datepicker "TypeError: Vue.use is not a function"

Am I doing something wrong? When using the nc-datepicker I get a warning inside of the browser's console.
[Vue warn]: Error in render: "TypeError: Vue.use is not a function"

When I change from
import DatePicker from 'nextcloud-vue' to import DatePicker from 'vue2-datepicker' the datepicker works great.

My main.js:

import Vue from 'vue'
import Create from './Create.vue'
//import DatePicker from 'vue2-datepicker'
import DatePicker from 'nextcloud-vue'

Vue.component('DatePickerInput', DatePicker);

new Vue({
  el: '#create-poll',
  render: h => h(Create)
});

My Create.vue

<template>
	<div id="create-poll" class="flex-column">
		<date-picker-input placeholder="Expiration date" v-model="expire" ></date-picker-input>
	</div>
</template>

<script>
	export default {
		name: 'create-poll',

		data: function () {
			return {
			expire: '',
			}
		}
	}
	
</script>

`NavigationItem` should allow simple click actions

In order to use this component for Mail, I need to add an entry to the app navigation for the expand/collapse folders feature. This entry neither points to an external URL, nor is it connected to the Vue router. It's a simple "button" with a click action.

Would that be possible, @skjnldsv?

Provide color picker

There should be a standardised color-picker in Nextcloud because it's needed in many places.
E.g.:

This is the color-picker in the Calendar app (v1):
Safari, IE:
55d7a0ab-ac58-4ea7-8ccd-70f6baa5a3cd

Firefox, Chrome, Edge:
cbcfbb97-beb7-4d25-a678-40c04ee397f3

It provides a default set of colors plus a random color option in Safari, IE and a real color-picker for browsers that natively support it.
https://caniuse.com/#feat=input-color

The color-picker should also work inside the popover menu.

Linter fails

$ npm run lint

> [email protected] lint nextcloud-vue
> eslint --ext .js,.vue src tests


Oops! Something went wrong! :(

ESLint: 5.6.0.
No files matching the pattern "tests" were found.
Please check for typing mistakes in the pattern.

Expose v-tooltip as component

Right now if an app uses v-tooltip the source is actually contained twice in the bundle, one time in the nextcloud vue-components and one time for the actual use inside of the app bundle.

Maybe it would make sense to just expose the tooltip lib we use in the components, so apps can use that as well.

Add translation plugin

Should we add translated string in this lib or make the devs add their own?
I like the idea of a standard coming directly from here.
It would probably be stuff like "No more results" or "An error has occurred" I guess. No big sentences, but still.

We should make sure developpers can dynamically import stuff from us so they don't load every language then :)

Any opinions?
@nextcloud/vue

Named slots support for popover-menu

There are many special needs for the popover-menu (like a color input in calendar or the delete confirmation in tasks) that do not make sense to be implement in vue-components itself.
Therefore popovermenu should allow to hand over named slots to provide individual popover-menu items.

Multiselect fixes

  • Pre-translate the error messages so that users doesn't have to do it?
  • Fix slots not working since we do not forward them to the select component
  • Fix design of the checkbox icon on single select (maybe use an arrow instead, the checkbox is confusing on single select)

Action component

As discussed with @skjnldsv and @jancborchardt we should add a action component that will take a list of actions and render the action icon directly if there is only one. If multiple actions are added, a 3-dots menu with a popover menu should be shown.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.