Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds SVG to Json for SharePoint List Web Part #5338

Open
wants to merge 98 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 94 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
35560f9
adds first draft of a webpart sample
LuiseFreese Oct 16, 2024
88921f7
Automated samples.json update
actions-user Oct 16, 2024
2384acc
modifies sample to also display a preview of the SVG
LuiseFreese Oct 16, 2024
a870011
Merge branch 'main' of https://github.com/LuiseFreese/sp-dev-fx-webparts
LuiseFreese Oct 16, 2024
79b89ac
implements apply to a column on a list of your choice in a given site…
LuiseFreese Oct 16, 2024
4c30127
some debugging and solidifying
LuiseFreese Oct 16, 2024
94c08b3
adds info about new features in Readme and addds video and image
LuiseFreese Oct 16, 2024
aebee9e
attempts to fix link
LuiseFreese Oct 16, 2024
8262311
attempts to fix link 2
LuiseFreese Oct 16, 2024
2284bfa
attempts to fix link 3
LuiseFreese Oct 16, 2024
ad6cf36
attempts to fix link 4
LuiseFreese Oct 16, 2024
2dd424d
attempts to fix link 4
LuiseFreese Oct 16, 2024
ea29677
attempts to fix link 4
LuiseFreese Oct 16, 2024
552a6c4
adds image
LuiseFreese Oct 16, 2024
2ad57f0
adds property pane with Site URL and libraryName
LuiseFreese Oct 17, 2024
57f5639
rms unneccessary styling, excludes doc libary
LuiseFreese Oct 18, 2024
2ba476c
splits up the logic into several components
LuiseFreese Oct 18, 2024
2f62995
uses PnPjs for fetchSVGfiles
LuiseFreese Oct 18, 2024
4efd404
uses PnP.js for applyColumnFormatting
LuiseFreese Oct 18, 2024
3a6190e
uses PnP.js for fetching listcolumns
LuiseFreese Oct 18, 2024
6dbd58c
adds option to select the site the format shall be applied to
LuiseFreese Oct 19, 2024
2cc94ed
adjusts readme to reflect site selector
LuiseFreese Oct 19, 2024
7bbd0de
moves handleFileChange to SVGInput
LuiseFreese Oct 19, 2024
0205f96
moves applyColumnFormat to ApplyButton.tsx
LuiseFreese Oct 19, 2024
4340a32
adsjusts property pane to tell users what they need to do
LuiseFreese Oct 19, 2024
d21db08
adds aria labels for better accessibility
LuiseFreese Oct 19, 2024
2416f04
comments
LuiseFreese Oct 19, 2024
23241e7
separates ListColumnSelector in ListSelector and ColumnSelector
LuiseFreese Oct 19, 2024
6ad68df
big fix that precented the apply btn to work correctly
LuiseFreese Oct 19, 2024
d562849
adds custom hooks to fetch lists and columns
LuiseFreese Oct 19, 2024
e389586
typo fixes in README
LuiseFreese Oct 19, 2024
5b64f2b
adds reset feature to applybutton
LuiseFreese Oct 19, 2024
bcbb2b3
applies bug fix that prevented applyColumn to work properly
LuiseFreese Oct 19, 2024
cf60e71
adds pic and ref to blog to readme
LuiseFreese Oct 19, 2024
1ed2362
first attempt to make it also work in Teams
LuiseFreese Oct 19, 2024
e96c059
fixes styling issues and minor bugs
LuiseFreese Oct 20, 2024
2cb262e
small UI improvement wit accordeon
LuiseFreese Oct 20, 2024
d6d62bc
moves Teams configuration to child component
LuiseFreese Oct 20, 2024
6c41101
basic usage in Teams prep and updatew of readme
LuiseFreese Oct 20, 2024
7440bde
adds imgae
LuiseFreese Oct 20, 2024
933f9d9
corrects link for image
LuiseFreese Oct 20, 2024
a2b6ade
adds minimal validation of property pane values.
LuiseFreese Oct 21, 2024
bd1bc9a
PnPjs improvements
LuiseFreese Oct 21, 2024
3b571e0
prepares for loc
LuiseFreese Oct 21, 2024
f48bb06
no no hard coded strings anymore
LuiseFreese Nov 1, 2024
6c3460f
Automated samples.json update
actions-user Nov 1, 2024
3c497f5
adds docs
LuiseFreese Nov 1, 2024
4cc859e
Merge branch 'main' of https://github.com/LuiseFreese/sp-dev-fx-webparts
LuiseFreese Nov 1, 2024
325ab90
:bulb: elaborates on component logic, adds mermaid
LuiseFreese Nov 1, 2024
da9e9f8
:bulb: elaborates on component logic, adds mermaid
LuiseFreese Nov 1, 2024
35a9848
:fire: removes old toggleswitch
LuiseFreese Nov 1, 2024
4470b5a
hooks and service
LuiseFreese Nov 2, 2024
e4154f6
:art: creates useFetchSites hook
LuiseFreese Nov 2, 2024
ac9be97
:speech_balloon: improves localization
LuiseFreese Nov 2, 2024
125e6d1
:speech_balloon: improves localization
LuiseFreese Nov 2, 2024
cd91899
:sparkles: new genz locale and new de-de locale
LuiseFreese Nov 2, 2024
b2533e3
:bug: adds strings in locale files
LuiseFreese Nov 2, 2024
4c63e74
:memo: adds info on multilanguage to readme
LuiseFreese Nov 2, 2024
f9130f6
:memo: clarifies readme
LuiseFreese Nov 2, 2024
26c03de
:tada: early draft of ultimate listformatting webpart
LuiseFreese Nov 3, 2024
bbdb65b
:zap: adds pagination to gallery
LuiseFreese Nov 3, 2024
04399f2
:see_no_evil: adds env
LuiseFreese Nov 3, 2024
e0d6fee
:bug: debugs pagination
LuiseFreese Nov 4, 2024
42667fd
:bug: fixes pagination
LuiseFreese Nov 4, 2024
5a95897
:art: 4 rows of items in gallerty, fixes apply button hook
LuiseFreese Nov 4, 2024
1c943cd
:sparkles: adds author name and profile pic
LuiseFreese Nov 4, 2024
6db9c14
Revert ":sparkles: adds author name and profile pic"
LuiseFreese Nov 4, 2024
a93b5ba
:sparkles: adds author name and profile pic
LuiseFreese Nov 4, 2024
5873128
:sparkles: adds search
LuiseFreese Nov 4, 2024
1484508
:sparkles: adds modal
LuiseFreese Nov 7, 2024
520b4dc
:bug: fixes open in github link
LuiseFreese Nov 8, 2024
ac7deac
:ambulance: replaces fake token with placeholder
LuiseFreese Nov 8, 2024
47a6fe0
Automated samples.json update
actions-user Nov 8, 2024
4451efb
:zap: adds browser caching and lazy loading
LuiseFreese Nov 8, 2024
3297be5
Merge branch 'main' of https://github.com/LuiseFreese/sp-dev-fx-webparts
LuiseFreese Nov 8, 2024
bf7fa51
:heavy_plus_sign: adds octokit
LuiseFreese Nov 8, 2024
d23480b
:memo: adds Readme information
LuiseFreese Nov 8, 2024
2f61d67
:zap: fixes search
LuiseFreese Nov 8, 2024
473a9a1
:art: creates hooks for SampleSelection, Pagination, Modal
LuiseFreese Nov 8, 2024
1f1587a
:memo: updates mermaid
LuiseFreese Nov 8, 2024
db64bbb
:memo: updates mermaid 2
LuiseFreese Nov 8, 2024
9f0282e
:sparkles: adds provide feedback option.
LuiseFreese Nov 9, 2024
889993f
:lipstick: polishes description
LuiseFreese Nov 9, 2024
ad71d9c
:memo: lets mermaid and features align with recent changes
LuiseFreese Nov 9, 2024
f58b565
adds tourfile
LuiseFreese Nov 10, 2024
f805a54
:fire: removes 2nd sample for now
LuiseFreese Nov 10, 2024
94216dc
:memo: adds nvmrc file
LuiseFreese Nov 10, 2024
ffd0d1e
:tada: first draft of bluesky web part
LuiseFreese Nov 12, 2024
b7247ef
:tada: creates first draft of Bluesky webpart
LuiseFreese Nov 12, 2024
803b22e
Revert ":tada: creates first draft of Bluesky webpart"
LuiseFreese Nov 12, 2024
b85d554
Merge branch 'pnp:main' into main
LuiseFreese Nov 12, 2024
bbbdb20
Merge branch 'main' of https://github.com/LuiseFreese/sp-dev-fx-webparts
LuiseFreese Nov 12, 2024
fdc2989
:memo: provides Readme info
LuiseFreese Nov 12, 2024
c3e2291
removes bluesky sample from PR
LuiseFreese Nov 18, 2024
c7c9e19
:fire: adds bluesky web part sample with basic features
LuiseFreese Nov 19, 2024
c31dfbe
:sparkles: adds feature to LIKE posts
LuiseFreese Nov 20, 2024
62daecf
:bug: fixes sharecount
LuiseFreese Nov 20, 2024
3b1c809
Merge branch 'main' into main
hugoabernier Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions samples/react-svg-to-json-converter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Logs
logs
*.log
npm-debug.log*

# Dependency directories
node_modules

# Build generated files
dist
lib
release
solution
temp
*.sppkg
.heft

# Coverage directory used by tools like istanbul
coverage

# OSX
.DS_Store

# Visual Studio files
.ntvs_analysis.dat
.vs
bin
obj

# Resx Generated Code
*.resx.ts

# Styles Generated Code
*.scss.ts
16 changes: 16 additions & 0 deletions samples/react-svg-to-json-converter/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
!dist
config

gulpfile.js

release
src
temp

tsconfig.json
tslint.json

*.log

.yo-rc.json
.vscode
1 change: 1 addition & 0 deletions samples/react-svg-to-json-converter/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.20.4
72 changes: 72 additions & 0 deletions samples/react-svg-to-json-converter/.tours/svgtojsonwebpart.tour
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"$schema": "https://aka.ms/codetour-schema",
"title": "SVGtoJsonWEbPart",
"steps": [
{
"file": "README.md",
"description": "Start in the ReadMe and get an overview of the architecture of the Web Part. It consists of a Parent component, several child components and some React hooks. ",
"line": 1
},
{
"file": "src/webparts/svgToJson/SvgToJsonWebPart.ts",
"description": "We first take care of the Property pane by letting our user define on which Site URL and Library Name we can find the SVGs",
"line": 59
},
{
"file": "src/webparts/svgToJson/components/SvgToJson.tsx",
"description": "When in SharePoint, we now use the Parent component as an orchestrator for all other child components. ",
"line": 98
},
{
"file": "src/webparts/svgToJson/components/SVGInput.tsx",
"description": "The SVG Input will take care of displaying the dropdown menu with our SVGs - it does so by calling the useSVGFiles hook",
"line": 16
},
{
"file": "src/webparts/svgToJson/components/useSvgFiles.ts",
"description": "we fetch the Files from the specified SiteUrl and library",
"line": 9
},
{
"file": "src/webparts/svgToJson/components/ConvertButton.tsx",
"description": "with the convert button, we extract all the 'd' and 'fill' attributes from the SVG code and wrap it into the json format that will be accepted by a SharePoint List column.",
"line": 23
},
{
"file": "src/webparts/svgToJson/components/SiteSelector.tsx",
"description": "We will now in the SiteSelector call the useFetchSites hook",
"line": 15
},
{
"file": "src/webparts/svgToJson/components/useFetchSites.ts",
"description": "to populate the dropdown menu with all Site Collections",
"line": 13
},
{
"file": "src/webparts/svgToJson/components/ListSelector.tsx",
"description": "then we will use the ListSelector and call the useFetchLists hook...",
"line": 13
},
{
"file": "src/webparts/svgToJson/components/useFetchLists.ts",
"description": "to populate the Lists dropdown menue (while excluding all the lists that shouldn't show up)",
"line": 12
},
{
"file": "src/webparts/svgToJson/components/ColumnSelector.tsx",
"description": "In the ColumnSelector finally, we show the columns in the selected List by calling the useFetchFields hook...",
"line": 14
},
{
"file": "src/webparts/svgToJson/components/useFetchFields.ts",
"description": "so that all the fields get populated in the ColumnSelector",
"line": 17
},
{
"file": "src/webparts/svgToJson/components/ApplyButton.tsx",
"description": "as a last step, we will apply the format we created previously to the selected column in the selected list on the selected site and open the spedcified list in a new tab so that we can verify the format has been applied correctly",
"line": 43
}
],
"ref": "main"
}
24 changes: 24 additions & 0 deletions samples/react-svg-to-json-converter/.yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"@microsoft/generator-sharepoint": {
"whichFolder": "subdir",
"solutionName": "svg-converter-solution",
"componentType": "webpart",
"template": "react",
"componentName": "SVG to JSON for SharePoint List formatter",
"plusBeta": false,
"isCreatingSolution": true,
"nodeVersion": "18.20.4",
"sdksVersions": {
"@microsoft/microsoft-graph-client": "3.0.2",
"@microsoft/teams-js": "2.24.0"
},
"version": "1.20.0",
"libraryName": "svg-converter-solution",
"libraryId": "42e52dfa-95dd-4cbd-8ba3-9cfb4ba4a644",
"environment": "spo",
"packageManager": "npm",
"solutionShortDescription": "svg-converter-solution description",
"skipFeatureDeployment": true,
"isDomainIsolated": false
}
}
111 changes: 111 additions & 0 deletions samples/react-svg-to-json-converter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# svg-converter-solution

## Summary

This web part allows users to read SVGs from a SharePoint library, select one of them and have the code converted into a JSON format that is ready to be used in a SharePoint List in advanced formatting. Users can both copy the JSON format to their clipboard (for further manipulation) or select a site, a list, and a column and then directly apply the format to this column.

For usage in SharePoint, the Property Pane is used to define the Site URL and the library Name where the SVGs come from, for usage in Microsoft Teams there is a basic form to save the configuration.

Web Part works in both english and german and can easily be extended to work in more languages.

![svg converter in action](../react-svg-to-json-converter/assets/webpart-sp.png)

## Overview of the Web Part

This Web Part is designed to allow users to select an SVG file from a SharePoint library, convert it to JSON format, and apply that JSON format to a SharePoint List column. The Web Part is built using React and leverages the PnPjs library.

```mermaid
graph TD
A[SvgToJson.tsx] --> B[SVGInput.tsx]
A --> C[SVGOutput.tsx]
A --> D[ConvertButton.tsx]
A --> E[SiteSelector.tsx]
A --> F[ListColumnSelector.tsx]
A --> G[ColumnSelector.tsx]
A --> H[ApplyButton.tsx]

B --> I[Fetch SVG files from SharePoint library]
D --> J[Convert SVG to JSON]
D --> K[Copy JSON to clipboard]
E --> L[Fetch available sites]
F --> M[Fetch available lists from site]
G --> N[Fetch available columns from selected list]
H --> O[Apply JSON to SharePoint list column]
```

## Key Components

* SvgToJson.tsx: This is the main component of the web part. It orchestrates the overall functionality by integrating other components like SVGInput, SVGOutput, ConvertButton, ApplyButton, and ListColumnSelector.

* SVGInput.tsx: This component is responsible for fetching and displaying the list of SVG files from the specified SharePoint library. It uses a dropdown to allow users to select an SVG file.
* SVGOutput.tsx: This component displays the content of the selected SVG file. It provides a visual preview of the SVG.
* ConvertButton.tsx: This component provides a button to convert the selected SVG content to JSON format. It also copies the JSON to the clipboard.
* SiteSelector.tsx: This component allows users to select a SharePoint Site. It fetches all Site Collections in the tenant.
* ListSelector.tsx: This component allows users to select a SharePoint List. It fetches the available lists from the specified site.
* ColumnSelector.tsx: This component allows users to select a Column. It fetches the available columns from the specified site.
* ApplyButton.tsx: This component provides a button to apply the JSON format to the specified SharePoint List column. It handles the logic for updating the column formatting.

## Example Workflow

* Select Site and Library: The user selects a **SharePoint Site** and **library** from which to fetch SVG files.
* Select SVG File: The user selects an **SVG file** from the dropdown in the SVGInput component.
* Display SVG Content: The selected SVG content is displayed in the SVGOutput component.
* Convert SVG to JSON: The user selects the **ConvertButton** to convert the SVG content to JSON format. The JSON is copied to the clipboard.
* Select List and Column: The user selects a **SharePoint List** and **column** using the ListColumnSelector component.
* Apply JSON Format: The user selects the **ApplyButton** to apply the JSON format to the selected column.

## Conclusion

This web part provides a user-friendly interface for selecting, converting, and applying SVG files to SharePoint list columns. It leverages React for the UI and PnPjs for SharePoint operations, to ensure a seamless integration with SharePoint. By breaking down the functionality into modular components, the web part is easy to maintain and extend.

If you want to read more about this Web Part, [this blog post series is for you](https://m365princess.com/blogs/spfx-1)

## Used SharePoint Framework Version

![version](https://img.shields.io/badge/version-1.20.0-green.svg)

## Applies to

- [SharePoint Framework](https://aka.ms/spfx)
- [Microsoft 365 tenant](https://docs.microsoft.com/sharepoint/dev/spfx/set-up-your-developer-tenant)

> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)

## Prerequisites

In the property pane, you can enter a SharePoint Site URL and a library name on that SharePoint Site where SVGs can be selected from.

## Solution

| Solution | Author(s) |
| ----------- | ------------------------------------------------------- |
| react-svg-to-json-converter | [Luise Freese](https://github.com/LuiseFreese) | @LuiseFreese |

## Version history

| Version | Date | Comments |
| ------- | ---------------- | --------------- |
| 1.0 | November 1 | Initial release |

## Disclaimer

**THIS CODE IS PROVIDED _AS IS_ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**

---

## Minimal Path to Awesome

- Clone this repository
- Ensure that you are at the solution folder
- in the command-line run:
- **npm install**
- **gulp serve**
> Include any additional steps as needed.

## References

- [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
- [Building for Microsoft teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview)
- [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
- [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview)
- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development
Loading
Loading