From 016b06c0c9da46256b2c81f89f08ea50be2fc8e8 Mon Sep 17 00:00:00 2001 From: Ville Eriksson Date: Thu, 24 Oct 2024 14:55:21 +0300 Subject: [PATCH] Update docs --- .../pages/getting-started/angular.vue | 84 ++----- .../pages/getting-started/react.vue | 235 +----------------- 2 files changed, 19 insertions(+), 300 deletions(-) diff --git a/packages/csc-ui-documentation/pages/getting-started/angular.vue b/packages/csc-ui-documentation/pages/getting-started/angular.vue index 653457a0..8ed02cea 100644 --- a/packages/csc-ui-documentation/pages/getting-started/angular.vue +++ b/packages/csc-ui-documentation/pages/getting-started/angular.vue @@ -8,9 +8,9 @@

1. Install the required dependencies

This command will install the CSC Design system component library @cscfi/csc-ui - and the control value accessor - csc-ui-accessor - which allows the components to support 2-way model binding. -

- -

- - 2. Add the following lines to - main.ts - -

- - - -

- - 3. Configure - AppModule - to use the control value accessor and CUSTOM_ELEMENTS_SCHEMA. - + .

- -

- - 4. Add the following line to - styles.scss - + 2. Add the following line to your css file.

- Now you should be able to use the CSC Design system components in your - project. Please note that the components require the control value - accessor - cControl - as an additional attribute to enable 2-way binding with - [(ngModel)] - or - Angular reactive forms - . + Working example with 2-way binding

+ +
diff --git a/packages/csc-ui-documentation/pages/getting-started/react.vue b/packages/csc-ui-documentation/pages/getting-started/react.vue index bc44f003..bd8f7a99 100644 --- a/packages/csc-ui-documentation/pages/getting-started/react.vue +++ b/packages/csc-ui-documentation/pages/getting-started/react.vue @@ -41,20 +41,7 @@ />

- 3. Use in your React components -

- - - -

- Working example + Working example with 2-way binding

@@ -69,224 +56,8 @@ onMounted(() => { sdk.embedProjectId('react-example', 'vitejs-vite-d6igeu', { forceEmbedLayout: true, openFile: 'src/App.tsx', + height: '1000px', + view: 'preview', }); }); - -const appTsx = `import { useState } from 'react'; -import { - CMain, - CToolbar, - CCscLogo, - CSideNavigation, - CSideNavigationItem, - CSideNavigationTitle, - CSubNavigationItem, - CPage, - CCard, - CCardTitle, - CCardContent, - CCardActions, - CTable, - CAlert, - CButton, - CModal, - CTextField, - CToasts, -} from '@cscfi/csc-ui-react'; -import { CAlertType, CToastMessage } from '@cscfi/csc-ui'; -import './App.css'; -import { useRef } from 'react'; - -function App() { - const toastRef = useRef(null); - - const [users, setUsers] = useState([ - { id: 1, name: 'Jason Miller', age: 23 }, - { id: 2, name: 'Silvia Nyholm', age: 18 }, - { id: 3, name: 'Mark Samsonov', age: 56 }, - { id: 4, name: 'Michael Nielsen', age: 29 }, - ]); - - const [isModalOpen, setIsModalOpen] = useState(false); - const [name, setName] = useState(''); - const [age, setAge] = useState(0); - - const onAddUser = () => { - setUsers([...users, { name, age, id: users.length + 1 }]); - - setIsModalOpen(false); - - const message: CToastMessage = { - message: 'New user added', - }; - - toastRef.current?.addToast(message); - - setName(''); - setAge(0); - - console.log(name, age); - }; - - const onOpenDialog = () => { - setIsModalOpen(true); - }; - - const onRemoveUser = (id: number) => { - setUsers(users.filter((user) => user.id !== id)); - }; - - const getCurrentYear = () => new Date().getFullYear(); - - return ( - <> - - - - CSC UI React - - - - About - - Two level navigation - - - Examples - Html - Javascript - - - - Logout - - - - - - Dashboard layout - - - -

Using the layout

- The default layout can be disabled using the 'disable-layout' - prop -
- - - - - - - - - - - - - - - - - {users.map((user) => ( - - - - - - - - - - ))} - {!users.length && ( - - - - )} - -
IdNameAge
{user.id}{user.name}{user.age} -
- onRemoveUser(user.id)} - > - Delete - -
-
No more users to delete
-
-
- - - onOpenDialog()}>Add user - -
- -
- {getCurrentYear()} - CSC Design system -
-
- - ) => - setIsModalOpen(event.detail) - } - > - - Add a new user - - -

User Id: {users.length + 1}

- - ) => - setName(event.detail) - } - > - - ) => - setAge(+event.detail) - } - > -
- - - setIsModalOpen(false)} text> - Cancel - - onAddUser()}>Add user - -
-
- - -
- - ); -} - -export default App; -`;