Skip to content

Commit 3a3dbb1

Browse files
committed
minor #225 [WIP] Refactoring all docs to .rst files to host on symfony.com (weaverryan)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [WIP] Refactoring all docs to .rst files to host on symfony.com | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Tickets | None | License | MIT This preps the docs so that they can be hosted on symfony.com/bundles. TODO: * [X] a partner PR on symfony-docs to update some URLs and other things there symfony/symfony-docs#16404 * [x] Javier to be ready to integrate this into symfony.com after merge Commits ------- 71a9db3 Merge branch '2.x' into rst_docs e6aeda3 minor docs tweaks 604f177 delegating most of main README to Symfony docs 86ba8ab linking to new UX section fb05d24 Refactoring all docs to .rst files to host on symfony.com
2 parents 6c39a68 + 71a9db3 commit 3a3dbb1

File tree

28 files changed

+3625
-3389
lines changed

28 files changed

+3625
-3389
lines changed

README.md

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,55 +9,20 @@
99
Symfony UX is an initiative and set of libraries to seamlessly
1010
integrate JavaScript tools into your application. For example,
1111
want to render a chart with [Chart.js](https://www.chartjs.org/)? Use
12-
[UX Chart.js](https://github.com/symfony/ux-chartjs)
12+
[UX Chart.js](https://symfony.com/bundles/ux-chartjs/current/index.html)
1313
to build the chart in PHP. The JavaScript is handled for you automatically.
1414

1515
**That's Symfony UX.**
1616

17-
[Read all the details about the Symfony UX initiative](https://symfony.com/ux)
18-
19-
Or watch the [Stimulus Screencast on SymfonyCasts](https://symfonycasts.com/screencast/stimulus).
20-
21-
## Components of UX
22-
2317
Symfony UX leverages [Stimulus](https://stimulus.hotwired.dev/) for JavaScript
2418
and the [Stimulus Bridge](https://github.com/symfony/stimulus-bridge) for
2519
integrating it into [Webpack Encore](https://github.com/symfony/webpack-encore).
2620

27-
## Packages
28-
29-
- [UX Chart.js](https://github.com/symfony/ux-chartjs):
30-
[Chart.js](https://www.chartjs.org/) chart library integration for Symfony
31-
- [UX Cropper.js](https://github.com/symfony/ux-cropperjs):
32-
[Cropper.js](https://fengyuanchen.github.io/cropperjs/) image cropper library integration for Symfony
33-
- [UX Dropzone](https://github.com/symfony/ux-dropzone):
34-
File input drag-and-drop zones for Symfony Forms
35-
- [UX LazyImage](https://github.com/symfony/ux-lazy-image):
36-
Improve image loading performances through lazy-loading and data-uri thumbnails
37-
- [UX Swup](https://github.com/symfony/ux-swup):
38-
[Swup](https://swup.js.org/) page transition library integration for Symfony
39-
- [UX Turbo](https://github.com/symfony/ux-turbo): [Hotwire Turbo](https://turbo.hotwired.dev/) library integration for Symfony
40-
- [Twig Component](https://github.com/symfony/ux-twig-component):
41-
A system to build reusable "components" with Twig
42-
- [Live Component](https://github.com/symfony/ux-live-component):
43-
Gives Twig Components a URL and a JavaScript library to automatically re-render via Ajax as your user interacts with it
44-
45-
## Stimulus Tools around the World
46-
47-
Because Stimulus is used by developers outside of Symfony, many tools
48-
exist beyond the UX packages:
49-
50-
- [stimulus-use](https://github.com/stimulus-use/stimulus-use): Add composable
51-
behaviors to your Stimulus controllers, like [debouncing](https://stimulus-use.github.io/stimulus-use/#/use-debounce),
52-
[detecting outside clicks](https://stimulus-use.github.io/stimulus-use/#/use-click-outside)
53-
and many other things. See: https://stimulus-use.github.io/stimulus-use/#/
21+
## Resources
5422

55-
- [stimulus-components](https://stimulus-components.netlify.app/): A
56-
large number of pre-made Stimulus controllers, like for
57-
[Copying to clipboard](https://stimulus-components.netlify.app/docs/components/stimulus-clipboard/),
58-
[Sortable](https://stimulus-components.netlify.app/docs/components/stimulus-sortable/),
59-
[Popover](https://stimulus-components.netlify.app/docs/components/stimulus-popover/) (similar to tooltips)
60-
and much more.
23+
- [Install Symfony UX](https://symfony.com/doc/current/frontend/ux.html).
24+
- [List of UX Packages](https://symfony.com/doc/current/frontend/ux.html#ux-packages-list).
25+
- Watch the [Stimulus Screencast on SymfonyCasts](https://symfonycasts.com/screencast/stimulus).
6126

6227
## Let's build an amazing ecosystem together
6328

@@ -68,7 +33,7 @@ fields of your Symfony forms? Or the ability to make the `EntityType` render wit
6833
[AJAX auto-completion](https://tarekraafat.github.io/autoComplete.js)? Anything you
6934
do in JavaScript could be done streamlined as a UX package.
7035

71-
We have some ideas and we will release more packages in the coming days. The rest
36+
We have some ideas, and we will release more packages in the coming days. The rest
7237
is on you: let's create an amazing ecosystem together!
7338

7439
## Contributing

src/Chartjs/.symfony.bundle.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
branches: ["2.x"]
2+
maintained_branches: ["2.x"]
3+
doc_dir: "Resources/doc"

src/Chartjs/README.md

Lines changed: 7 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -3,161 +3,12 @@
33
Symfony UX Chart.js is a Symfony bundle integrating the [Chart.js](https://www.chartjs.org/)
44
library in Symfony applications. It is part of [the Symfony UX initiative](https://symfony.com/ux).
55

6-
## Installation
6+
**This repository is a READ-ONLY sub-tree split**. See
7+
https://github.com/symfony/ux to create issues or submit pull requests.
78

8-
Symfony UX Chart.js requires PHP 7.2+ and Symfony 4.4+.
9+
## Resources
910

10-
Install this bundle using Composer and Symfony Flex:
11-
12-
```sh
13-
composer require symfony/ux-chartjs
14-
15-
# Don't forget to install the JavaScript dependencies as well and compile
16-
yarn install --force
17-
yarn encore dev
18-
```
19-
20-
Also make sure you have at least version 3.0 of [@symfony/stimulus-bridge](https://github.com/symfony/stimulus-bridge)
21-
in your `package.json` file.
22-
23-
## Usage
24-
25-
To use Symfony UX Chart.js, inject the `ChartBuilderInterface` service and
26-
create charts in PHP:
27-
28-
```php
29-
// ...
30-
use Symfony\UX\Chartjs\Builder\ChartBuilderInterface;
31-
use Symfony\UX\Chartjs\Model\Chart;
32-
33-
class HomeController extends AbstractController
34-
{
35-
#[Route('/', name: 'app_homepage')]
36-
public function index(ChartBuilderInterface $chartBuilder): Response
37-
{
38-
$chart = $chartBuilder->createChart(Chart::TYPE_LINE);
39-
40-
$chart->setData([
41-
'labels' => ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
42-
'datasets' => [
43-
[
44-
'label' => 'My First dataset',
45-
'backgroundColor' => 'rgb(255, 99, 132)',
46-
'borderColor' => 'rgb(255, 99, 132)',
47-
'data' => [0, 10, 5, 2, 20, 30, 45],
48-
],
49-
],
50-
]);
51-
52-
$chart->setOptions([
53-
'scales' => [
54-
'y' => [
55-
'suggestedMin' => 0,
56-
'suggestedMax' => 100,
57-
],
58-
],
59-
]);
60-
61-
return $this->render('home/index.html.twig', [
62-
'chart' => $chart,
63-
]);
64-
}
65-
}
66-
```
67-
68-
All options and data are provided as-is to Chart.js. You can read
69-
[Chart.js documentation](https://www.chartjs.org/docs/latest/) to discover them all.
70-
71-
Once created in PHP, a chart can be displayed using Twig if installed
72-
(requires [Symfony Webpack Encore](https://symfony.com/doc/current/frontend/encore/installation.html)):
73-
74-
```twig
75-
{{ render_chart(chart) }}
76-
77-
{# You can pass HTML attributes as a second argument to add them on the <canvas> tag #}
78-
{{ render_chart(chart, {'class': 'my-chart'}) }}
79-
```
80-
81-
### Extend the default behavior
82-
83-
Symfony UX Chart.js allows you to extend its default behavior using a custom Stimulus controller:
84-
85-
```js
86-
// mychart_controller.js
87-
88-
import { Controller } from '@hotwired/stimulus';
89-
90-
export default class extends Controller {
91-
connect() {
92-
this.element.addEventListener('chartjs:pre-connect', this._onPreConnect);
93-
this.element.addEventListener('chartjs:connect', this._onConnect);
94-
}
95-
96-
disconnect() {
97-
// You should always remove listeners when the controller is disconnected to avoid side effects
98-
this.element.removeEventListener('chartjs:pre-connect', this._onPreConnect);
99-
this.element.removeEventListener('chartjs:connect', this._onConnect);
100-
}
101-
102-
_onPreConnect(event) {
103-
// The chart is not yet created
104-
console.log(event.detail.options); // You can access the chart options using the event details
105-
106-
// For instance you can format Y axis
107-
event.detail.options.scales = {
108-
yAxes: [
109-
{
110-
ticks: {
111-
callback: function (value, index, values) {
112-
/* ... */
113-
},
114-
},
115-
},
116-
],
117-
};
118-
}
119-
120-
_onConnect(event) {
121-
// The chart was just created
122-
console.log(event.detail.chart); // You can access the chart instance using the event details
123-
124-
// For instance you can listen to additional events
125-
event.detail.chart.options.onHover = (mouseEvent) => {
126-
/* ... */
127-
};
128-
event.detail.chart.options.onClick = (mouseEvent) => {
129-
/* ... */
130-
};
131-
}
132-
}
133-
```
134-
135-
Then in your render call, add your controller as an HTML attribute:
136-
137-
```twig
138-
{{ render_chart(chart, {'data-controller': 'mychart'}) }}
139-
```
140-
141-
## Backward Compatibility promise
142-
143-
This bundle aims at following the same Backward Compatibility promise as the Symfony framework:
144-
[https://symfony.com/doc/current/contributing/code/bc.html](https://symfony.com/doc/current/contributing/code/bc.html)
145-
146-
However it is currently considered
147-
[**experimental**](https://symfony.com/doc/current/contributing/code/experimental.html),
148-
meaning it is not bound to Symfony's BC policy for the moment.
149-
150-
## Run tests
151-
152-
### PHP tests
153-
154-
```sh
155-
php vendor/bin/phpunit
156-
```
157-
158-
### JavaScript tests
159-
160-
```sh
161-
cd Resources/assets
162-
yarn test
163-
```
11+
- [Documentation](https://symfony.com/bundles/ux-chartjs/current/index.html)
12+
- [Report issues](https://github.com/symfony/ux/issues) and
13+
[send Pull Requests](https://github.com/symfony/ux/pulls)
14+
in the [main Symfony UX repository](https://github.com/symfony/ux)

0 commit comments

Comments
 (0)